summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2017-07-29 21:37:16 -0700
committerGitHub <noreply@github.com>2017-07-29 21:37:16 -0700
commit17ded47a1324c54cf76e8486b900515242f3ae43 (patch)
treee2d5504a81b08fb2da2ff8135fbcecbb988dd09c
parentd9d4aefd3b66a183677aaf167911a5ead76c1752 (diff)
downloadwabt-17ded47a1324c54cf76e8486b900515242f3ae43.tar.gz
wabt-17ded47a1324c54cf76e8486b900515242f3ae43.tar.bz2
wabt-17ded47a1324c54cf76e8486b900515242f3ae43.zip
Fix tee_local typechecking bug w/ polymorphic stack (#587)
The previous type-checking code just made sure the value on the top of the stack is the correct type. This isn't sufficient when the stack is polymorphic, because the concrete type is not pushed onto the stack.
-rw-r--r--src/type-checker.cc6
-rw-r--r--test/regress/regress-10.txt13
2 files changed, 15 insertions, 4 deletions
diff --git a/src/type-checker.cc b/src/type-checker.cc
index 72b86cb4..7c14b6db 100644
--- a/src/type-checker.cc
+++ b/src/type-checker.cc
@@ -528,10 +528,8 @@ Result TypeChecker::OnTryBlock(const TypeVector* sig) {
Result TypeChecker::OnTeeLocal(Type type) {
Result result = Result::Ok;
- Type value = Type::Any;
- COMBINE_RESULT(result, CheckTypeStackLimit(1, "tee_local"));
- COMBINE_RESULT(result, TopType(&value));
- COMBINE_RESULT(result, CheckType(value, type, "tee_local"));
+ COMBINE_RESULT(result, PopAndCheck1Type(type, "tee_local"));
+ PushType(type);
return result;
}
diff --git a/test/regress/regress-10.txt b/test/regress/regress-10.txt
new file mode 100644
index 00000000..299f73a9
--- /dev/null
+++ b/test/regress/regress-10.txt
@@ -0,0 +1,13 @@
+;;; ERROR: 1
+(module
+ (func
+ (local i32)
+ block
+ unreachable
+ tee_local 0
+ end))
+(;; STDERR ;;;
+out/test/regress/regress-10.txt:7:7: error: type stack at end of block is 1, expected 0
+ tee_local 0
+ ^^^^^^^^^^^
+;;; STDERR ;;)