Skip to content

Commit

Permalink
Revert "Parser: Fix restrict grammar for name and supertype in type d…
Browse files Browse the repository at this point in the history
…ef (#12622)" (#12977)
  • Loading branch information
straight-shoota authored Jan 19, 2023
1 parent 643c8e5 commit 29291fb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
11 changes: 0 additions & 11 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,6 @@ module Crystal
assert_syntax_error "foo { |(#{kw})| }", "cannot use '#{kw}' as a block parameter name", 1, 9
end

describe "literals in class definitions" do
# #11209
%w("a" 'a' [1] {1} {|a|a} ->{} ->(x : Bar){} :Bar :bar %x() %w() %()).each do |invalid|
assert_syntax_error "class Foo#{invalid}; end"
assert_syntax_error "class Foo#{invalid} < Baz; end"
assert_syntax_error "class Foo#{invalid} < self; end"
assert_syntax_error "class Foo < Baz#{invalid}; end"
assert_syntax_error "class Foo < self#{invalid}; end"
end
end

it_parses "def self.foo\n1\nend", Def.new("foo", body: 1.int32, receiver: "self".var)
it_parses "def self.foo()\n1\nend", Def.new("foo", body: 1.int32, receiver: "self".var)
it_parses "def self.foo=\n1\nend", Def.new("foo=", body: 1.int32, receiver: "self".var)
Expand Down
10 changes: 0 additions & 10 deletions src/compiler/crystal/syntax/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1685,10 +1685,6 @@ module Crystal
name = parse_path
skip_space

unexpected_token unless @token.type.op_lt? || # Inheritance
@token.type.op_lparen? || # Generic Arguments
is_statement_end?

type_vars, splat_index = parse_type_vars

superclass = nil
Expand All @@ -1701,8 +1697,6 @@ module Crystal
else
superclass = parse_generic
end

unexpected_token unless @token.type.space? || is_statement_end?
end
skip_statement_end

Expand All @@ -1722,10 +1716,6 @@ module Crystal
class_def
end

def is_statement_end?
@token.type.newline? || @token.type.op_semicolon? || @token.keyword?(:end)
end

def parse_type_vars
type_vars = nil
splat_index = nil
Expand Down

0 comments on commit 29291fb

Please sign in to comment.