Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 6 additions & 4 deletions snapshots/booleans.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
@ ProgramNode (location: (1,0)-(3,4))
@ ProgramNode (location: (1,0)-(5,1))
├── flags: ∅
├── locals: []
└── statements:
@ StatementsNode (location: (1,0)-(3,4))
@ StatementsNode (location: (1,0)-(5,1))
├── flags: ∅
└── body: (length: 2)
└── body: (length: 3)
├── @ FalseNode (location: (1,0)-(1,5))
│ └── flags: newline, static_literal
└── @ TrueNode (location: (3,0)-(3,4))
├── @ TrueNode (location: (3,0)-(3,4))
│ └── flags: newline, static_literal
└── @ TrueNode (location: (5,0)-(5,1))
└── flags: newline, static_literal
5 changes: 3 additions & 2 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -6889,7 +6889,7 @@ pm_symbol_node_to_string_node(pm_parser_t *parser, pm_symbol_node_t *node) {
*/
static pm_true_node_t *
pm_true_node_create(pm_parser_t *parser, const pm_token_t *token) {
assert(token->type == PM_TOKEN_KEYWORD_TRUE);
assert(token->type == PM_TOKEN_KEYWORD_TRUE || token->type == PM_TOKEN_COLON);

return pm_true_node_new(
parser->arena,
Expand Down Expand Up @@ -11009,7 +11009,7 @@ parser_lex(pm_parser_t *parser) {
LEX(PM_TOKEN_COLON_COLON);
}

if (lex_state_end_p(parser) || pm_char_is_whitespace(peek(parser)) || peek(parser) == '#') {
if (lex_state_end_p(parser) || pm_char_is_whitespace(peek(parser)) || peek(parser) == '#' || peek(parser) == '\0') {
lex_state_set(parser, PM_LEX_STATE_BEG);
LEX(PM_TOKEN_COLON);
}
Expand Down Expand Up @@ -19989,6 +19989,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, u
case PM_TOKEN_KEYWORD_SELF:
parser_lex(parser);
return UP(pm_self_node_create(parser, &parser->previous));
case PM_TOKEN_COLON:
case PM_TOKEN_KEYWORD_TRUE:
parser_lex(parser);
return UP(pm_true_node_create(parser, &parser->previous));
Expand Down
2 changes: 2 additions & 0 deletions test/prism/fixtures/booleans.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
false

true

:
3 changes: 3 additions & 0 deletions test/prism/ruby/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class ParserTest < TestCase

# https://bugs.ruby-lang.org/issues/21168#note-5
"command_method_call_2.txt",

# Contains standalone `:` keyword (not supported by parser gem).
"booleans.txt",
]

# These files contain code that is being parsed incorrectly by the parser
Expand Down
3 changes: 3 additions & 0 deletions test/prism/ruby/ripper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class RipperTest < TestCase
]
end

# CRuby doesn't support standalone `:` as a keyword (equivalent to `true`).
incorrect << "booleans.txt"

# https://bugs.ruby-lang.org/issues/21669
incorrect << "4.1/void_value.txt"
# https://bugs.ruby-lang.org/issues/19107
Expand Down
3 changes: 3 additions & 0 deletions test/prism/ruby/ruby_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class RubyParserTest < TestCase

# https://bugs.ruby-lang.org/issues/21168#note-5
"command_method_call_2.txt",

# Contains standalone `:` keyword (not supported by ruby_parser).
"booleans.txt",
]

Fixture.each_for_version(version: "3.3", except: failures) do |fixture|
Expand Down
Loading