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

Parser: Don't skip the token immediately after lib name #13407

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,8 @@ module Crystal

it_parses "macro foo; bar class: 1; end", Macro.new("foo", body: MacroLiteral.new(" bar class: 1; "))

assert_syntax_error "lib Foo%end", %(unexpected token: "%")

describe "end locations" do
assert_end_location "nil"
assert_end_location "false"
Expand Down
4 changes: 2 additions & 2 deletions spec/support/syntax.cr
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class Crystal::ASTNode
end
end

def assert_syntax_error(str, message = nil, line = nil, column = nil, metafile = __FILE__, metaline = __LINE__, metaendline = __END_LINE__)
it "says syntax error on #{str.inspect}", metafile, metaline, metaendline do
def assert_syntax_error(str, message = nil, line = nil, column = nil, metafile = __FILE__, metaline = __LINE__, metaendline = __END_LINE__, *, focus : Bool = false)
it "says syntax error on #{str.inspect}", metafile, metaline, metaendline, focus: focus do
FnControlOption marked this conversation as resolved.
Show resolved Hide resolved
begin
parse str
fail "Expected SyntaxException to be raised", metafile, metaline
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/syntax/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5589,7 +5589,7 @@ module Crystal

name_location = @token.location
name = parse_path
next_token_skip_statement_end
skip_statement_end

body = push_visibility { parse_lib_body_expressions }

Expand Down