Skip to content

Commit 30d998e

Browse files
authored
Fix location for "invalid trailing comma in call" errors (#13964)
1 parent 8e1a9cc commit 30d998e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

spec/compiler/parser/parser_spec.cr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,13 +2087,14 @@ module Crystal
20872087
end
20882088
)
20892089

2090-
assert_syntax_error %(
2090+
assert_syntax_error <<-CRYSTAL, "invalid trailing comma in call", line: 2, column: 8
20912091
if 1
20922092
foo 1,
20932093
end
2094-
), "invalid trailing comma in call"
2094+
CRYSTAL
2095+
2096+
assert_syntax_error "foo 1,", "invalid trailing comma in call", line: 1, column: 6
20952097

2096-
assert_syntax_error "foo 1,", "invalid trailing comma in call"
20972098
assert_syntax_error "def foo:String\nend", "a space is mandatory between ':' and return type"
20982099
assert_syntax_error "def foo :String\nend", "a space is mandatory between ':' and return type"
20992100
assert_syntax_error "def foo():String\nend", "a space is mandatory between ':' and return type"

src/compiler/crystal/syntax/parser.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4753,7 +4753,7 @@ module Crystal
47534753
location = @token.location
47544754
slash_is_regex!
47554755
next_token_skip_space_or_newline
4756-
raise "invalid trailing comma in call" if (@token.keyword?(:end) && !next_comes_colon_space?) || @token.type.eof?
4756+
raise "invalid trailing comma in call", location if (@token.keyword?(:end) && !next_comes_colon_space?) || @token.type.eof?
47574757
else
47584758
break
47594759
end

0 commit comments

Comments
 (0)