aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/language/evaluatorscriptclass.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-02-21 14:59:38 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2018-02-23 08:34:08 +0000
commit153b9d8b4117bcf8e0b10f7368991e4d4f676a50 (patch)
tree48cfe7f7b4924fa4337d2c73b36d66d5271b1b2e /src/lib/corelib/language/evaluatorscriptclass.cpp
parent8ba501a462058202f913b742f35e2d858e6c11e7 (diff)
Add a location to errors in conditions of Properties items
These can be exceedingly difficult to debug otherwise. Change-Id: Ie3bc42fbd60e11be105fc23624c77a623dc5f1aa Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/lib/corelib/language/evaluatorscriptclass.cpp')
-rw-r--r--src/lib/corelib/language/evaluatorscriptclass.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp
index 0a3f4d4c5..5a0eec865 100644
--- a/src/lib/corelib/language/evaluatorscriptclass.cpp
+++ b/src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -252,6 +252,12 @@ private:
bool hasError = false;
};
+ void injectErrorLocation(QScriptValue &sv, const CodeLocation &loc)
+ {
+ if (sv.isError() && !engine->lastErrorLocation(sv).isValid())
+ sv = engine->currentContext()->throwError(engine->lastError(sv, loc).toString());
+ }
+
JSSourceValueEvaluationResult evaluateJSSourceValue(const JSSourceValue *value, Item *outerItem,
const JSSourceValue::Alternative *alternative = nullptr,
JSSourceValue *elseCaseValue = nullptr, QScriptValue *outerScriptValue = nullptr)
@@ -283,10 +289,11 @@ private:
pushScope(maybeExtraScope.first);
pushScope(fileCtxScopes.importScope);
if (alternative) {
- QScriptValue sv = engine->evaluate(alternative->condition);
+ QScriptValue sv = engine->evaluate(alternative->condition.value);
if (engine->hasErrorOrException(sv)) {
result.scriptValue = sv;
result.hasError = true;
+ injectErrorLocation(result.scriptValue, alternative->condition.location);
return result;
}
if (sv.toBool()) {
@@ -297,10 +304,12 @@ private:
result.tryNextAlternative = true;
return result;
}
- sv = engine->evaluate(alternative->overrideListProperties);
+ sv = engine->evaluate(alternative->overrideListProperties.value);
if (engine->hasErrorOrException(sv)) {
result.scriptValue = sv;
result.hasError = true;
+ injectErrorLocation(result.scriptValue,
+ alternative->overrideListProperties.location);
return result;
}
if (sv.toBool())