Skip to content

Commit b4478c6

Browse files
Fix allow space after base type in enum def (#16217)
1 parent 759378d commit b4478c6

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

spec/compiler/parser/parser_spec.cr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,8 @@ module Crystal
20332033
it_parses "enum Foo; A\nB; C\nD = 1; end", EnumDef.new("Foo".path, [Arg.new("A"), Arg.new("B"), Arg.new("C"), Arg.new("D", 1.int32)] of ASTNode)
20342034
it_parses "enum Foo; A = 1; B; end", EnumDef.new("Foo".path, [Arg.new("A", 1.int32), Arg.new("B")] of ASTNode)
20352035
it_parses "enum Foo : UInt16; end", EnumDef.new("Foo".path, base_type: "UInt16".path)
2036+
it_parses "enum Foo : UInt16 ; end", EnumDef.new("Foo".path, base_type: "UInt16".path)
2037+
it_parses "enum Foo : UInt16 # comment\nend", EnumDef.new("Foo".path, base_type: "UInt16".path)
20362038
it_parses "enum Foo; def foo; 1; end; end", EnumDef.new("Foo".path, [Def.new("foo", body: 1.int32)] of ASTNode)
20372039
it_parses "enum Foo; A = 1\ndef foo; 1; end; end", EnumDef.new("Foo".path, [Arg.new("A", 1.int32), Def.new("foo", body: 1.int32)] of ASTNode)
20382040
it_parses "enum Foo; A = 1\ndef foo; 1; end\ndef bar; 2; end\nend", EnumDef.new("Foo".path, [Arg.new("A", 1.int32), Def.new("foo", body: 1.int32), Def.new("bar", body: 2.int32)] of ASTNode)

src/compiler/crystal/syntax/parser.cr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6135,6 +6135,7 @@ module Crystal
61356135
if @token.type.op_colon?
61366136
next_token_skip_space_or_newline
61376137
base_type = parse_path
6138+
skip_space
61386139
end
61396140

61406141
check SemicolonOrNewLine

0 commit comments

Comments
 (0)