Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-45043] Import Prism 0.27.0 #3553

Merged
merged 5 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions spec/ruby/language/break_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,25 @@ def mid(&b)
end
end

describe "The break statement in a method" do
it "is invalid and raises a SyntaxError" do
-> {
eval("def m; break; end")
}.should raise_error(SyntaxError)
end
end

describe "The break statement in a module literal" do
it "is invalid and raises a SyntaxError" do
code = <<~RUBY
module BreakSpecs:ModuleWithBreak
break
end
RUBY

-> { eval(code) }.should raise_error(SyntaxError)
end
end

# TODO: Rewrite all the specs from here to the end of the file in the style
# above.
Expand Down
5 changes: 4 additions & 1 deletion spec/ruby/language/retry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
results.should == [1, 2, 3, 1, 2, 4, 5, 6, 4, 5]
end

it "raises a SyntaxError when used outside of a begin statement" do
it "raises a SyntaxError when used outside of a rescue statement" do
-> { eval 'retry' }.should raise_error(SyntaxError)
-> { eval 'begin; retry; end' }.should raise_error(SyntaxError)
-> { eval 'def m; retry; end' }.should raise_error(SyntaxError)
-> { eval 'module RetrySpecs; retry; end' }.should raise_error(SyntaxError)
end
end

Expand Down
12 changes: 12 additions & 0 deletions spec/ruby/language/yield_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,15 @@ class << Object.new
-> { eval(code) }.should raise_error(SyntaxError, /Invalid yield/)
end
end

describe "Using yield in a module literal" do
it 'raises a SyntaxError' do
code = <<~RUBY
module YieldSpecs::ModuleWithYield
yield
end
RUBY

-> { eval(code) }.should raise_error(SyntaxError, /Invalid yield/)
end
end
6 changes: 6 additions & 0 deletions spec/truffle/parsing/fixtures/TOPLEVEL_BINDING.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ ast: |
flags = 0
sourceCharIndex = -1
sourceLength = 0
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - a', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 1))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
6 changes: 6 additions & 0 deletions spec/truffle/parsing/fixtures/__END__.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ ast: |
flags = 0
sourceCharIndex = -1
sourceLength = 0
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - a', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 1))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 51
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - array', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 53
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - array', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 52
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - array', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 34
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 52
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - array', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 52
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - array', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 41
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
6 changes: 6 additions & 0 deletions spec/truffle/parsing/fixtures/for/with_class_variable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 37
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
6 changes: 6 additions & 0 deletions spec/truffle/parsing/fixtures/for/with_constant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 33
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 39
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
6 changes: 6 additions & 0 deletions spec/truffle/parsing/fixtures/for/with_global_variable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 35
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
6 changes: 6 additions & 0 deletions spec/truffle/parsing/fixtures/for/with_instance_variable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 35
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
6 changes: 6 additions & 0 deletions spec/truffle/parsing/fixtures/for/with_local_variable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 33
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 45
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ast: |
sourceLength = 57
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - b', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 2))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ ast: |
sourceLength = 8
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'assigned but unused variable - foo', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 1))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
7 changes: 5 additions & 2 deletions spec/truffle/parsing/fixtures/retry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ subject: "retry"
description: "retry control flow operator"
focused_on_node: "org.truffleruby.language.control.RetryNode"
ruby: |
retry
begin
rescue
retry
end
ast: |
RetryNode
attributes:
flags = 1
sourceCharIndex = 0
sourceCharIndex = 15
sourceLength = 5
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ ast: |
sourceLength = 18
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'possibly useless use of a literal in void context', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 1))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ ast: |
sourceLength = 16
children:
body = [
EmitWarningsNode
attributes:
flags = 0
sourceCharIndex = -1
sourceLength = 0
warnings = RubyDeferredWarnings(WarningMessage(message = 'possibly useless use of a literal in void context', verbosity = VERBOSE, fileName = '<parse_ast>', lineNumber = 1))
WriteLocalVariableNode
attributes:
flags = 0
Expand Down