From 75c7f093e0b8e321306ae1189b71866a9073df00 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 21 Oct 2019 09:27:57 +0200 Subject: QML: Resolve conflict in ImportSpecifier rule IdentifierReference could resolve to both ImpordBinding and IdentifierName, causing ambiguity in the grammar, and ultimately caused parse failues when parsing an import statement. This is now resolved by explicitly telling the parser to prefer shifting. This is a partial cherry-pick. Apparently the effect observed in the original change and fixed inline can also be triggered in different ways. (cherry-picked from commit 41bbf7e376d0e374dc7c4e2a5ed4157a1b880b4a) Fixes: QTBUG-80423 Change-Id: Iaec29c452b577312248a17cb48f005f4fc0bd8c4 Reviewed-by: Fabian Kosmale --- src/qml/parser/qqmljs.g | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index 8ac7633ae0..0d9507fe2f 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -122,6 +122,7 @@ --%left T_PLUS T_MINUS %nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY T_ON T_SET T_GET T_OF T_STATIC T_FROM T_AS %nonassoc REDUCE_HERE +%right T_WITHOUTAS T_AS %start TopLevel @@ -4390,7 +4391,10 @@ ImportsList: ImportsList T_COMMA ImportSpecifier; } break; ./ -ImportSpecifier: ImportedBinding; +-- When enconutering an IdentifierReference it can resolve to both ImportedBinding and IdentifierName +-- Using %right and %prec, we tell qlalr that it should not reduce immediately, but rather shift +-- so that we have a chance of actually parsing the correct rule if there is an "as" identifier +ImportSpecifier: ImportedBinding %prec T_WITHOUTAS; /. case $rule_number: { auto importSpecifier = new (pool) AST::ImportSpecifier(stringRef(1)); -- cgit v1.2.3