Skip to content

Commit

Permalink
Fix parse error when quoted required keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Nov 20, 2023
1 parent 3d6c825 commit 71bf388
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/rbs_extension/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ static void parse_params(parserstate *state, method_params *params) {

case tUIDENT:
case tLIDENT:
case tQIDENT:
case tULIDENT:
case tULLIDENT:
case tBANGIDENT:
Expand Down
8 changes: 8 additions & 0 deletions test/rbs/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,14 @@ def test_parse_method_type
assert_equal "?foo, ?foo: String", method_type.type.param_to_s
end

RBS::Parser.parse_method_type(buffer("(`foo`: String) -> void")).tap do |method_type|
assert_equal "`foo`: String", method_type.type.param_to_s
end

RBS::Parser.parse_method_type(buffer("(?`foo`: String) -> void")).tap do |method_type|
assert_equal "?`foo`: String", method_type.type.param_to_s
end

RBS::Parser.parse_method_type(buffer("(1) -> void")).tap do |method_type|
assert_equal "1", method_type.type.param_to_s
end
Expand Down
1 change: 1 addition & 0 deletions test/rbs/types_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_to_s
assert_equal "(^() -> void)?", parse_type("(^() -> void)?").to_s
assert_equal "^(bool flag, ?untyped, *Symbol, name: String, ?email: nil, **Symbol) -> void", parse_type("^(bool flag, ?untyped, *Symbol, name: String, ?email: nil, **Symbol) -> void").to_s
assert_equal "^(untyped untyped, untyped footype) -> void", parse_type("^(untyped `untyped`, untyped footype) -> void").to_s
assert_equal "^(`foo`: untyped) -> void", parse_type("^(`foo`: untyped) -> void").to_s
end

def test_has_self_type?
Expand Down

0 comments on commit 71bf388

Please sign in to comment.