ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:118270] [Ruby master Bug#20571] Compile error on for loop
@ 2024-06-10 13:52 kddnewton (Kevin Newton) via ruby-core
  2024-07-29 23:54 ` [ruby-core:118725] " jeremyevans0 (Jeremy Evans) via ruby-core
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2024-06-10 13:52 UTC (permalink / raw)
  To: ruby-core; +Cc: kddnewton (Kevin Newton)

Issue #20571 has been reported by kddnewton (Kevin Newton).

----------------------------------------
Bug #20571: Compile error on for loop
https://bugs.ruby-lang.org/issues/20571

* Author: kddnewton (Kevin Newton)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
```ruby
for _ in 1.5 or _ in []
end
```

raises a compile error for the current compiler only with

```
-- raw disasm--------
   trace: 1
 <L000> [sp: 0, unremovable: 1, refcnt: 1]
   0000 putobject            1.5                                         (   1)
   0002 jump                 <L002>                                      (   1)
 <L006> [sp: 1, unremovable: 1, refcnt: 1]
 <L004> [sp: 1, unremovable: 0, refcnt: 0]
   0004 pop                                                              (   1)
*  0005 pop                                                              (   1)
   0006 putobject            false                                       (   1)
 <L002> [sp: 1, unremovable: 0, refcnt: 1]
   0008 send                 <calldata:each, 0>, nil                     (   1)
 <L001> [sp: -1, unremovable: 0, refcnt: 2]
   0011 leave                                                            (   1)
---------------------
test.rb:1: argument stack underflow (-1)
test.rb: compile error (SyntaxError)
```



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:118725] [Ruby master Bug#20571] Compile error on for loop
  2024-06-10 13:52 [ruby-core:118270] [Ruby master Bug#20571] Compile error on for loop kddnewton (Kevin Newton) via ruby-core
@ 2024-07-29 23:54 ` jeremyevans0 (Jeremy Evans) via ruby-core
  2024-07-30  0:49 ` [ruby-core:118726] " jeremyevans0 (Jeremy Evans) via ruby-core
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2024-07-29 23:54 UTC (permalink / raw)
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #20571 has been updated by jeremyevans0 (Jeremy Evans).


I looked into this and was able to determine the underlying cause (currently on line 7844 of `compile.c`):

```c
ADD_INSN(cond_seq, line_node, pop); /* discard cached #deconstruct value */ 
```

Commenting that out fixes the example, though it causes overflow elsewhere.  Most likely the `pop` instruction needs to be conditional, or we are missing a `dup` instruction somewhere.

----------------------------------------
Bug #20571: Compile error on for loop
https://bugs.ruby-lang.org/issues/20571#change-109260

* Author: kddnewton (Kevin Newton)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
```ruby
for _ in 1.5 or _ in []
end
```

raises a compile error for the current compiler only with

```
-- raw disasm--------
   trace: 1
 <L000> [sp: 0, unremovable: 1, refcnt: 1]
   0000 putobject            1.5                                         (   1)
   0002 jump                 <L002>                                      (   1)
 <L006> [sp: 1, unremovable: 1, refcnt: 1]
 <L004> [sp: 1, unremovable: 0, refcnt: 0]
   0004 pop                                                              (   1)
*  0005 pop                                                              (   1)
   0006 putobject            false                                       (   1)
 <L002> [sp: 1, unremovable: 0, refcnt: 1]
   0008 send                 <calldata:each, 0>, nil                     (   1)
 <L001> [sp: -1, unremovable: 0, refcnt: 2]
   0011 leave                                                            (   1)
---------------------
test.rb:1: argument stack underflow (-1)
test.rb: compile error (SyntaxError)
```



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:118726] [Ruby master Bug#20571] Compile error on for loop
  2024-06-10 13:52 [ruby-core:118270] [Ruby master Bug#20571] Compile error on for loop kddnewton (Kevin Newton) via ruby-core
  2024-07-29 23:54 ` [ruby-core:118725] " jeremyevans0 (Jeremy Evans) via ruby-core
@ 2024-07-30  0:49 ` jeremyevans0 (Jeremy Evans) via ruby-core
  2024-08-18  2:19 ` [ruby-core:118871] " nagachika (Tomoyuki Chikanaga) via ruby-core
  2024-09-02 10:05 ` [ruby-core:119008] " k0kubun (Takashi Kokubun) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2024-07-30  0:49 UTC (permalink / raw)
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #20571 has been updated by jeremyevans0 (Jeremy Evans).


After some additional work, I think this is an optimizer issue.  With `--dump=i,-opt`, both parse.y and prism generate the exact same instructions.  However, with `--dump=i`, prism does not raise an error, but parse.y does.  I'm not sure why the two would use different optimizers.

----------------------------------------
Bug #20571: Compile error on for loop
https://bugs.ruby-lang.org/issues/20571#change-109261

* Author: kddnewton (Kevin Newton)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
```ruby
for _ in 1.5 or _ in []
end
```

raises a compile error for the current compiler only with

```
-- raw disasm--------
   trace: 1
 <L000> [sp: 0, unremovable: 1, refcnt: 1]
   0000 putobject            1.5                                         (   1)
   0002 jump                 <L002>                                      (   1)
 <L006> [sp: 1, unremovable: 1, refcnt: 1]
 <L004> [sp: 1, unremovable: 0, refcnt: 0]
   0004 pop                                                              (   1)
*  0005 pop                                                              (   1)
   0006 putobject            false                                       (   1)
 <L002> [sp: 1, unremovable: 0, refcnt: 1]
   0008 send                 <calldata:each, 0>, nil                     (   1)
 <L001> [sp: -1, unremovable: 0, refcnt: 2]
   0011 leave                                                            (   1)
---------------------
test.rb:1: argument stack underflow (-1)
test.rb: compile error (SyntaxError)
```



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:118871] [Ruby master Bug#20571] Compile error on for loop
  2024-06-10 13:52 [ruby-core:118270] [Ruby master Bug#20571] Compile error on for loop kddnewton (Kevin Newton) via ruby-core
  2024-07-29 23:54 ` [ruby-core:118725] " jeremyevans0 (Jeremy Evans) via ruby-core
  2024-07-30  0:49 ` [ruby-core:118726] " jeremyevans0 (Jeremy Evans) via ruby-core
@ 2024-08-18  2:19 ` nagachika (Tomoyuki Chikanaga) via ruby-core
  2024-09-02 10:05 ` [ruby-core:119008] " k0kubun (Takashi Kokubun) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: nagachika (Tomoyuki Chikanaga) via ruby-core @ 2024-08-18  2:19 UTC (permalink / raw)
  To: ruby-core; +Cc: nagachika (Tomoyuki Chikanaga)

Issue #20571 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED to 3.1: REQUIRED, 3.2: DONE, 3.3: REQUIRED

ruby_3_2 commit:50399eebd96c76ce808ea4d84fe39693f585a531 merged revision(s) commit:1870505f478cc75993b296b7144a45137ace6937.

----------------------------------------
Bug #20571: Compile error on for loop
https://bugs.ruby-lang.org/issues/20571#change-109443

* Author: kddnewton (Kevin Newton)
* Status: Closed
* Backport: 3.1: REQUIRED, 3.2: DONE, 3.3: REQUIRED
----------------------------------------
```ruby
for _ in 1.5 or _ in []
end
```

raises a compile error for the current compiler only with

```
-- raw disasm--------
   trace: 1
 <L000> [sp: 0, unremovable: 1, refcnt: 1]
   0000 putobject            1.5                                         (   1)
   0002 jump                 <L002>                                      (   1)
 <L006> [sp: 1, unremovable: 1, refcnt: 1]
 <L004> [sp: 1, unremovable: 0, refcnt: 0]
   0004 pop                                                              (   1)
*  0005 pop                                                              (   1)
   0006 putobject            false                                       (   1)
 <L002> [sp: 1, unremovable: 0, refcnt: 1]
   0008 send                 <calldata:each, 0>, nil                     (   1)
 <L001> [sp: -1, unremovable: 0, refcnt: 2]
   0011 leave                                                            (   1)
---------------------
test.rb:1: argument stack underflow (-1)
test.rb: compile error (SyntaxError)
```



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:119008] [Ruby master Bug#20571] Compile error on for loop
  2024-06-10 13:52 [ruby-core:118270] [Ruby master Bug#20571] Compile error on for loop kddnewton (Kevin Newton) via ruby-core
                   ` (2 preceding siblings ...)
  2024-08-18  2:19 ` [ruby-core:118871] " nagachika (Tomoyuki Chikanaga) via ruby-core
@ 2024-09-02 10:05 ` k0kubun (Takashi Kokubun) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: k0kubun (Takashi Kokubun) via ruby-core @ 2024-09-02 10:05 UTC (permalink / raw)
  To: ruby-core; +Cc: k0kubun (Takashi Kokubun)

Issue #20571 has been updated by k0kubun (Takashi Kokubun).

Backport changed from 3.1: REQUIRED, 3.2: DONE, 3.3: REQUIRED to 3.1: REQUIRED, 3.2: DONE, 3.3: DONE

ruby_3_3 commit:6a4e79533b4454392f3afdfa0c4d35b763b68466.

----------------------------------------
Bug #20571: Compile error on for loop
https://bugs.ruby-lang.org/issues/20571#change-109583

* Author: kddnewton (Kevin Newton)
* Status: Closed
* Backport: 3.1: REQUIRED, 3.2: DONE, 3.3: DONE
----------------------------------------
```ruby
for _ in 1.5 or _ in []
end
```

raises a compile error for the current compiler only with

```
-- raw disasm--------
   trace: 1
 <L000> [sp: 0, unremovable: 1, refcnt: 1]
   0000 putobject            1.5                                         (   1)
   0002 jump                 <L002>                                      (   1)
 <L006> [sp: 1, unremovable: 1, refcnt: 1]
 <L004> [sp: 1, unremovable: 0, refcnt: 0]
   0004 pop                                                              (   1)
*  0005 pop                                                              (   1)
   0006 putobject            false                                       (   1)
 <L002> [sp: 1, unremovable: 0, refcnt: 1]
   0008 send                 <calldata:each, 0>, nil                     (   1)
 <L001> [sp: -1, unremovable: 0, refcnt: 2]
   0011 leave                                                            (   1)
---------------------
test.rb:1: argument stack underflow (-1)
test.rb: compile error (SyntaxError)
```



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-02 10:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-10 13:52 [ruby-core:118270] [Ruby master Bug#20571] Compile error on for loop kddnewton (Kevin Newton) via ruby-core
2024-07-29 23:54 ` [ruby-core:118725] " jeremyevans0 (Jeremy Evans) via ruby-core
2024-07-30  0:49 ` [ruby-core:118726] " jeremyevans0 (Jeremy Evans) via ruby-core
2024-08-18  2:19 ` [ruby-core:118871] " nagachika (Tomoyuki Chikanaga) via ruby-core
2024-09-02 10:05 ` [ruby-core:119008] " k0kubun (Takashi Kokubun) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).