-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compiler: correct to handle instance variable assignment inside block…
… on global (#4324) * Compiler: correct to handle instance variable assignment inside block on global Fix #4323 (comment)
- Loading branch information
1 parent
e270317
commit 3961dd0
Showing
2 changed files
with
42 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4685,4 +4685,39 @@ describe "Semantic: instance var" do | |
{Foo.new.@never_nil, Bar.new.@never_nil} | ||
)) { tuple_of([int32, int32]) } | ||
end | ||
|
||
it "errors if assigning instance variable at top level block" do | ||
assert_error %( | ||
def foo | ||
yield | ||
end | ||
foo do | ||
@foo = 1 | ||
end | ||
), | ||
"can't use instance variables at the top level" | ||
end | ||
|
||
it "errors when assigning instance variable at top level block" do | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
RX14
Contributor
|
||
assert_error %( | ||
def foo | ||
yield | ||
end | ||
foo do | ||
@foo = 1 | ||
end | ||
), | ||
"can't use instance variables at the top level" | ||
end | ||
|
||
it "errors when assigning instance variable at top level control block" do | ||
assert_error %( | ||
if true | ||
@foo = 1 | ||
end | ||
), | ||
"can't use instance variables at the top level" | ||
end | ||
end |
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 seems like a duplicate of the previous test. Is it supposed to test something different?