-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #1969: Make StaticScope and IRScope agree on var slot assignment
* IRBuilder was ignore duplicate "_" args in blocks whereas the parser would allocate slots in StaticScope for all of them. This effectively led the runtime to allocate DynamicScope with 1 fewer slot than what was required because a variable's slot id came from StaticScope but # variables for a DynamicScope came from IRScope. We are yet to find a way to clean up this static/lexical scope duplication/split from the old runtime. * Added a new spec/regression test.
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
- 9.1.2.0
- 9.1.1.0
- 9.1.0.0
- 9.0.5.0
- 9.0.4.0
- 9.0.3.0
- 9.0.1.0
- 9.0.0.0
- 9.0.0.0.rc2
- 9.0.0.0.rc1
- 9.0.0.0.pre2
- 9.0.0.0.pre1
Showing
3 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# https://github.com/jruby/jruby/issues/1969 | ||
|
||
def yielder; yield; end | ||
|
||
def foo; yield 1,2,3,4,5,6,7; end | ||
|
||
describe 'Blocks with duplicate _ args' do | ||
it 'should not crash' do | ||
foo do |x,_,_,_,a,b,c| | ||
bar {} | ||
[x,a,b,c] | ||
end.should_be [1,5,6,7] | ||
end | ||
end |
4303b57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make sense to assert
_
is assigned the correct value in the spec as well.4303b57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nirvdrum I was going to say relying on value of _ is weird, but I noticed we have a weird bug with '_':
'' binds to first actual value which is 1 but making an opt-arg out of second '' seems to bind the first value to 2?!?!?!
4303b57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@enebo My experience has suggested that if MRI has an undefined, but predictable behavior, someone out there has exploited it :-(
4303b57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nirvdrum
4303b57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@enebo So, you're saying we need more specs? Or that you, too, now hate everything? :-P
4303b57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha...yeah we should probably spec this out as well or report it as a bug. *_ overriding regular _ is pretty unexpected. Also first assignment wins is also weird. I would think last would win? I agree though someone no doubt uses _ for some nefarious purpose.
4303b57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
_
is fairly common in Scala and some other languages. My guess is a cross-language developer would do it without even thinking about it.4303b57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "def foo(_, =1, *); p ; end; foo(1,2) #=> []" is a MRI bug and should be fixed there. rubyspecs already has a spec for the use of "" in blocks.
4303b57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at the AST for each of these:
def foo(_, _); p ; end; foo(1,2)
def foo(, _=5); p _; end; foo(1,2)
def yielder; yield 1,2; end
yielder { |,| p _ }
yielder { |,=5| p _ }
I was relying on the presence of _$0 to detect duplicates, but in the case of the opt-arg scenario, both args are named _. This is actually a bigger issue than bad results .. it can potentially cause other crashers of the kind that I fixed in this patch.