Skip to content

Commit

Permalink
Revert "Merge pull request #1675 from ksss/parse-record-lit"
Browse files Browse the repository at this point in the history
This reverts commit d84612d, reversing
changes made to 4eb84e2.
  • Loading branch information
soutaro committed Dec 20, 2023
1 parent 481302e commit 9d5a6e0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
2 changes: 1 addition & 1 deletion ext/rbs_extension/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ VALUE parse_record_attributes(parserstate *state) {
case tINTEGER:
case kTRUE:
case kFALSE:
key = rb_funcall(parse_simple(state), rb_intern("literal"), 0);
key = rb_funcall(parse_type(state), rb_intern("literal"), 0);
break;
default:
raise_syntax_error(
Expand Down
27 changes: 0 additions & 27 deletions test/rbs/type_parsing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -669,33 +669,6 @@ def test_record
assert_equal "a.rbs:1:2...1:5: Syntax error: unexpected record key token, token=`foo` (tLIDENT)", error.message
end

def test_record_with_optional_key
error = assert_raises(RBS::ParsingError) do
Parser.parse_type("{ 1?: untyped }")
end
assert_equal "pQUESTION", error.token_type
assert_equal "?", error.location.source
assert_equal "a.rbs:1:3...1:4: Syntax error: expected a token `pFATARROW`, token=`?` (pQUESTION)", error.message
end

def test_record_with_intersection_key
error = assert_raises(RBS::ParsingError) do
Parser.parse_type("{ 1&2: untyped }")
end
assert_equal "pAMP", error.token_type
assert_equal "&", error.location.source
assert_equal "a.rbs:1:3...1:4: Syntax error: expected a token `pFATARROW`, token=`&` (pAMP)", error.message
end

def test_record_with_union_key
error = assert_raises(RBS::ParsingError) do
Parser.parse_type("{ 1|2: untyped }")
end
assert_equal "pBAR", error.token_type
assert_equal "|", error.location.source
assert_equal "a.rbs:1:3...1:4: Syntax error: expected a token `pFATARROW`, token=`|` (pBAR)", error.message
end

def test_type_var
Parser.parse_type("Array[A]", variables: []).yield_self do |type|
assert_instance_of Types::ClassInstance, type
Expand Down

0 comments on commit 9d5a6e0

Please sign in to comment.