summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-08-25 02:20:39 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-08-25 20:07:10 +0900
commit1f76e42b85be4031bdedcc3e457e8fa949195304 (patch)
treed6a8416d0f1c9c1fba5a11bcecb2e50b9abae644
parent023b8ddd220f2451b51490ee2e48dedb211e2d1b (diff)
[Bug #19848] Flush BOM
The token just after BOM needs to position at column 0, so that the indentation matches closing line.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8281
-rw-r--r--parse.y1
-rw-r--r--test/ruby/test_ast.rb6
2 files changed, 7 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 847a8e0933..cf8ae370aa 100644
--- a/parse.y
+++ b/parse.y
@@ -9021,6 +9021,7 @@ parser_prepare(struct parser_params *p)
}
#endif
p->lex.pbeg = p->lex.pcur;
+ token_flush(p);
return;
}
break;
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb
index 8b565f531d..b4bcc03cfe 100644
--- a/test/ruby/test_ast.rb
+++ b/test/ruby/test_ast.rb
@@ -1082,6 +1082,12 @@ dummy
assert_equal([[0, :backslash, "\\", [1, 0, 1, 1]]], node.children.last.tokens)
end
+ def test_with_bom
+ assert_error_tolerant("\u{feff}nil", <<~EXP)
+ (SCOPE@1:0-1:3 tbl: [] args: nil body: (NIL@1:0-1:3))
+ EXP
+ end
+
def assert_error_tolerant(src, expected, keep_tokens: false)
begin
verbose_bak, $VERBOSE = $VERBOSE, false