Skip to content

Commit

Permalink
[GR-45043] Import Prism 0.27.0
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/4253
  • Loading branch information
andrykonchin committed Apr 26, 2024
2 parents 902a537 + 94fde16 commit d226c36
Show file tree
Hide file tree
Showing 44 changed files with 2,869 additions and 843 deletions.
19 changes: 19 additions & 0 deletions spec/ruby/language/break_spec.rb
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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

0 comments on commit d226c36

Please sign in to comment.