aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-10-21 09:27:57 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-11-29 15:36:22 +0000
commit75c7f093e0b8e321306ae1189b71866a9073df00 (patch)
tree33edc7fb421b92091af9e5fbc654c1273ededfd0
parent5a2e7087cbb11fce1f0f510ae7eb08b1e70e9989 (diff)
QML: Resolve conflict in ImportSpecifier rulev5.14.0-rc1
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 <fabian.kosmale@qt.io>
-rw-r--r--src/qml/parser/qqmljs.g6
1 files changed, 5 insertions, 1 deletions
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));