Skip to content

Why does (= 0 nil) return false, but (= nil 0) return true? #1295

Answered by sogaiu
oadbd asked this question in Q&A
Discussion options

You must be logged in to vote

May be these are the lines in question (just following up on ianthehenry's analysis)?

janet/src/core/vm.c

Lines 863 to 865 in 910b9cf

VM_OP(JOP_EQUALS_IMMEDIATE)
stack[A] = janet_wrap_boolean(janet_unwrap_number(stack[B]) == (double) CS);
vm_pcnext();

janet/src/core/vm.c

Lines 871 to 873 in 910b9cf

VM_OP(JOP_NOT_EQUALS_IMMEDIATE)
stack[A] = janet_wrap_boolean(janet_unwrap_number(stack[B]) != (double) CS);
vm_pcnext();

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@oadbd
Comment options

@bidulock
Comment options

@ianthehenry
Comment options

@sogaiu
Comment options

Answer selected by bakpakin
@oadbd
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug This is not expected behavior, and needs fixing
5 participants