ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "ydah (Yudai Takada) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "ydah (Yudai Takada)" <noreply@ruby-lang.org>
Subject: [ruby-core:120418] [Ruby master Bug#20939] When using the parse.y parser, it occurs argument stack underflow (-1) if there is processing after the shareable_constant_value: experimental_everything comment and `C = { **{ k: v } }`
Date: Thu, 26 Dec 2024 12:02:55 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-111199.20241226120255.52290@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20939.20241210045654.52290@ruby-lang.org>

Issue #20939 has been updated by ydah (Yudai Takada).

Status changed from Open to Closed

Thank you. fixed by: https://github.com/ruby/ruby/pull/12338

----------------------------------------
Bug #20939: When using the parse.y parser, it occurs argument stack underflow (-1) if there is processing after the shareable_constant_value: experimental_everything comment and `C = { **{ k: v } }`
https://bugs.ruby-lang.org/issues/20939#change-111199

* Author: ydah (Yudai Takada)
* Status: Closed
* ruby -v: ruby 3.4.0dev (2024-12-10T03:31:47Z master f12e2622c1) [arm64-darwin23]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
The following code will occurs argument stack underflow if it is a parse.y parser.

```ruby
# shareable_constant_value: experimental_everything
C = { **{ k: v } }
p C
```
The following error message is output.

```
ruby 3.4.0dev (2024-12-06T03:32:20Z master 6ccaa37eb3) [arm64-darwin23]
-- raw disasm--------
   trace: 1
   0000 putspecialobject     1                                           (   2)
   0002 putobject            :k                                          (   2)
   0004 putself                                                          (   2)
   0005 opt_send_without_block <calldata:v, 0>                           (   2)
   0007 newhash              2                                           (   2)
   0009 newhash              2                                           (   2)
   0011 opt_send_without_block <calldata:make_shareable, 1>              (   2)
   0013 putspecialobject     3                                           (   2)
*  0015 setconstant          :C                                          (   2)
   trace: 1
   0017 putself                                                          (   3)
   0018 opt_getconstant_path [:C]                                        (   3)
   0020 opt_send_without_block <calldata:p, 1>                           (   3)
   0022 leave                                                            (   3)
---------------------
-e:2: argument stack underflow (-1)
-e: compile error (SyntaxError)
```

It does not occur in the following cases:

```ruby
# shareable_constant_value: experimental_everything
C = { **{ k: v } }
```

```ruby
C = { **{ k: v } }                           
p C
```

```ruby
# shareable_constant_value: experimental_everything
{ **{ k: v } }
p C
```

```ruby
# shareable_constant_value: experimental_everything
C = { **{ k: 1 } }
p C
```

This does not occur in Ruby 3.3:
```
❯ ruby --parser=parse.y -v -e '# shareable_constant_value: experimental_everything

C = { **{ foo: bar } }

p C'
ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin23]
-e:3:in `<main>': undefined local variable or method `bar' for main (NameError)

C = { **{ foo: bar } }
               ^^^
```



-- 
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/

      parent reply	other threads:[~2024-12-26 12:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-10  4:56 [ruby-core:120147] " ydah (Yudai Takada) via ruby-core
2024-12-13 15:58 ` [ruby-core:120231] " tompng (tomoya ishida) via ruby-core
2024-12-26 12:02 ` ydah (Yudai Takada) via ruby-core [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-111199.20241226120255.52290@ruby-lang.org \
    --to=ruby-core@ml.ruby-lang.org \
    --cc=noreply@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).