Skip to content

Commit d226c36

Browse files
committed
[GR-45043] Import Prism 0.27.0
PullRequest: truffleruby/4253
2 parents 902a537 + 94fde16 commit d226c36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2869
-843
lines changed

spec/ruby/language/break_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,25 @@ def mid(&b)
252252
end
253253
end
254254

255+
describe "The break statement in a method" do
256+
it "is invalid and raises a SyntaxError" do
257+
-> {
258+
eval("def m; break; end")
259+
}.should raise_error(SyntaxError)
260+
end
261+
end
262+
263+
describe "The break statement in a module literal" do
264+
it "is invalid and raises a SyntaxError" do
265+
code = <<~RUBY
266+
module BreakSpecs:ModuleWithBreak
267+
break
268+
end
269+
RUBY
270+
271+
-> { eval(code) }.should raise_error(SyntaxError)
272+
end
273+
end
255274

256275
# TODO: Rewrite all the specs from here to the end of the file in the style
257276
# above.

spec/ruby/language/retry_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@
3131
results.should == [1, 2, 3, 1, 2, 4, 5, 6, 4, 5]
3232
end
3333

34-
it "raises a SyntaxError when used outside of a begin statement" do
34+
it "raises a SyntaxError when used outside of a rescue statement" do
3535
-> { eval 'retry' }.should raise_error(SyntaxError)
36+
-> { eval 'begin; retry; end' }.should raise_error(SyntaxError)
37+
-> { eval 'def m; retry; end' }.should raise_error(SyntaxError)
38+
-> { eval 'module RetrySpecs; retry; end' }.should raise_error(SyntaxError)
3639
end
3740
end
3841

spec/ruby/language/yield_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,15 @@ class << Object.new
206206
-> { eval(code) }.should raise_error(SyntaxError, /Invalid yield/)
207207
end
208208
end
209+
210+
describe "Using yield in a module literal" do
211+
it 'raises a SyntaxError' do
212+
code = <<~RUBY
213+
module YieldSpecs::ModuleWithYield
214+
yield
215+
end
216+
RUBY
217+
218+
-> { eval(code) }.should raise_error(SyntaxError, /Invalid yield/)
219+
end
220+
end

spec/truffle/parsing/fixtures/TOPLEVEL_BINDING.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ ast: |
3939
flags = 0
4040
sourceCharIndex = -1
4141
sourceLength = 0
42+
EmitWarningsNode
43+
attributes:
44+
flags = 0
45+
sourceCharIndex = -1
46+
sourceLength = 0
47+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - a', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 1))
4248
WriteLocalVariableNode
4349
attributes:
4450
flags = 0

spec/truffle/parsing/fixtures/__END__.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ ast: |
4747
flags = 0
4848
sourceCharIndex = -1
4949
sourceLength = 0
50+
EmitWarningsNode
51+
attributes:
52+
flags = 0
53+
sourceCharIndex = -1
54+
sourceLength = 0
55+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - a', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 1))
5056
WriteLocalVariableNode
5157
attributes:
5258
flags = 0

spec/truffle/parsing/fixtures/for/multi_assignment/with_multiple_variables.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 51
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - array', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/multi_assignment/with_nested_multi_assignment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 53
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - array', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/multi_assignment/with_preceding_splat_operator_and_following_variables.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 52
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - array', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/multi_assignment/with_preceding_variables_and_implicit_rest.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 34
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/multi_assignment/with_preceding_variables_and_splat_operator.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 52
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - array', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/multi_assignment/with_splat_operator_and_following_variables.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 52
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - array', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/with_attribute_assignment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 41
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/with_class_variable.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 37
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/with_constant.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 33
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/with_fully_qualified_constant.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 39
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/with_global_variable.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 35
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/with_instance_variable.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 35
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/with_local_variable.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 33
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/with_reference_assignment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 45
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/for/with_reference_assignment_and_multiple_explicit_arguments.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ast: |
3535
sourceLength = 57
3636
children:
3737
body = [
38+
EmitWarningsNode
39+
attributes:
40+
flags = 0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
3844
WriteLocalVariableNode
3945
attributes:
4046
flags = 0

spec/truffle/parsing/fixtures/local_variables/at_top_level/writing.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ ast: |
3434
sourceLength = 8
3535
children:
3636
body = [
37+
EmitWarningsNode
38+
attributes:
39+
flags = 0
40+
sourceCharIndex = -1
41+
sourceLength = 0
42+
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - foo', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 1))
3743
WriteLocalVariableNode
3844
attributes:
3945
flags = 0

spec/truffle/parsing/fixtures/retry.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ subject: "retry"
22
description: "retry control flow operator"
33
focused_on_node: "org.truffleruby.language.control.RetryNode"
44
ruby: |
5-
retry
5+
begin
6+
rescue
7+
retry
8+
end
69
ast: |
710
RetryNode
811
attributes:
912
flags = 1
10-
sourceCharIndex = 0
13+
sourceCharIndex = 15
1114
sourceLength = 5

spec/truffle/parsing/fixtures/strings/with_interpolation_%_string_expression.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ ast: |
1111
sourceLength = 18
1212
children:
1313
body = [
14+
EmitWarningsNode
15+
attributes:
16+
flags = 0
17+
sourceCharIndex = -1
18+
sourceLength = 0
19+
warnings = RubyDeferredWarnings(WarningMessage(message = 'possibly useless use of a literal in void context', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 1))
1420
WriteLocalVariableNode
1521
attributes:
1622
flags = 0

spec/truffle/parsing/fixtures/strings/with_interpolation_string_expression.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ ast: |
1111
sourceLength = 16
1212
children:
1313
body = [
14+
EmitWarningsNode
15+
attributes:
16+
flags = 0
17+
sourceCharIndex = -1
18+
sourceLength = 0
19+
warnings = RubyDeferredWarnings(WarningMessage(message = 'possibly useless use of a literal in void context', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 1))
1420
WriteLocalVariableNode
1521
attributes:
1622
flags = 0

0 commit comments

Comments
 (0)