From 5df4c8bcfa94dc7136da75fa82230bba00cce579 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Thu, 15 Jul 2021 14:37:57 -0400 Subject: [PATCH] [Ruby 3.0] Reject ->... and ->(...) using the same error (#4367) * Import whitequark tests for the latest Ruby 3.0 parser changes * [Ruby 3.0] Reject ->... and ->(...) with the same error --- third_party/parser/cc/lexer.rl | 6 +++++- tools/scripts/import_whitequark.sh | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/third_party/parser/cc/lexer.rl b/third_party/parser/cc/lexer.rl index 43052f11b1d..8876de2e89c 100644 --- a/third_party/parser/cc/lexer.rl +++ b/third_party/parser/cc/lexer.rl @@ -2332,7 +2332,11 @@ void lexer::set_state_expr_value() { if (version >= ruby_version::RUBY_27) { emit(token_type::tBDOT3, ident, ts, te); } else { - emit(token_type::tDOT3, ident, ts, te); + if (!lambda_stack.empty() && lambda_stack.top() == paren_nest) { + emit(token_type::tDOT3, ident, ts, te); + } else { + emit(token_type::tBDOT3, ident, ts, te); + } } fnext expr_beg; fbreak; diff --git a/tools/scripts/import_whitequark.sh b/tools/scripts/import_whitequark.sh index 62de16246bb..aabbcd82abf 100755 --- a/tools/scripts/import_whitequark.sh +++ b/tools/scripts/import_whitequark.sh @@ -14,8 +14,8 @@ set -euo pipefail set -x -REF=b69e8e595b804fd8e70ee1b90fc6dee81e183126 -TARGET_RUBY_VERSION="2.7" +REF=49ed4dddfb1bf44d579fda001862149f4b9f7970 +TARGET_RUBY_VERSION="3.0" SCRIPT=$(realpath "$0") ROOT="$(cd "$(dirname "$SCRIPT")/../.."; pwd)"