aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4ssa.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@me.com>2013-08-29 11:13:04 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-08 13:17:37 +0200
commite9c502329465188bc6b178f3af676bd416b76d18 (patch)
tree017613d9372960555196139a2b59c25383995fa6 /src/qml/compiler/qv4ssa.cpp
parent4dbae9bda678de29ae82ea6cc88765f83e8d3f93 (diff)
V4: fix inferred types of 30&&true and 30||true.
The type was incorrectly inferred as double instead of var. Fixes ch10/10.5/10.5-7-b-3-s Change-Id: I93a43318a94a820a1a2e05c7b670a08915b99723 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4ssa.cpp')
-rw-r--r--src/qml/compiler/qv4ssa.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 0b663288ab..cd1aaa60d9 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -1419,11 +1419,28 @@ protected:
_ty.fullyTyped &= ty.fullyTyped;
}
- // TODO: check & double check the next condition!
- if (_ty.type & ObjectType || _ty.type & UndefinedType || _ty.type & NullType)
- _ty.type = ObjectType;
- else if (_ty.type & NumberType)
- _ty.type = DoubleType;
+ switch (_ty.type) {
+ case UndefinedType:
+ case NullType:
+ case BoolType:
+ case SInt32Type:
+ case UInt32Type:
+ case DoubleType:
+ case StringType:
+ case ObjectType:
+ // The type is not a combination of two or more types, so we're done.
+ break;
+
+ default:
+ // There are multiple types involved, so:
+ if ((_ty.type & NumberType) && !(_ty.type & ~NumberType))
+ // The type is any combination of double/int32/uint32, but nothing else. So we can
+ // type it as double.
+ _ty.type = DoubleType;
+ else
+ // There just is no single type that can hold this combination, so:
+ _ty.type = ObjectType;
+ }
setType(s->targetTemp, _ty.type);
}