Skip to content

Commit

Permalink
[PRISM] Implement PM_IMAGINARY_NODE for defined?
Browse files Browse the repository at this point in the history
Ruby Code:

```
defined?(1i)
```

Instructions:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,12)>
0000 putobject                              "expression"
0002 leave

"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,12)>
0000 putobject                              "expression"
0002 leave
```
  • Loading branch information
eileencodes authored and jemmaissroff committed Dec 6, 2023
1 parent d6ec1aa commit b04255d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions prism_compile.c
Expand Up @@ -1483,6 +1483,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *co
case PM_AND_NODE:
case PM_FLOAT_NODE:
case PM_HASH_NODE:
case PM_IMAGINARY_NODE:
case PM_INTEGER_NODE:
case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE:
case PM_INTERPOLATED_STRING_NODE:
Expand Down
1 change: 1 addition & 0 deletions test/ruby/test_compile_prism.rb
Expand Up @@ -96,6 +96,7 @@ def test_DefinedNode
assert_prism_eval("defined? true")
assert_prism_eval("defined? false")
assert_prism_eval("defined? 1")
assert_prism_eval("defined? 1i")
assert_prism_eval("defined? 1.0")
assert_prism_eval("defined? 1..2")
assert_prism_eval("defined? [A, B, C]")
Expand Down

0 comments on commit b04255d

Please sign in to comment.