feat: treat null as falsey in conditional and logical operator branches
Update the VM interpreter to treat null as falsey alongside false in if, while, for, and logical AND/OR operations. Remove the TODO comment and adjust short-circuit logic in OP_JUMP_IF and OP_JUMP_IF_NOT branches. Refactor existing test files into subdirectories (if/, logical_operator/, while/) and add dedicated truthiness tests for each construct. Remove old test/if.wren and update and/or tests to exclude null/0/"" truthiness checks now that null is falsey.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// False and null are false.
|
||||
IO.print(false && "bad") // expect: false
|
||||
IO.print(null && "bad") // expect: null
|
||||
|
||||
// Everything else is true.
|
||||
IO.print(true && "ok") // expect: ok
|
||||
IO.print(0 && "ok") // expect: ok
|
||||
IO.print("" && "ok") // expect: ok
|
||||
Reference in New Issue
Block a user