diff options
Diffstat (limited to 'src/passes/LocalSubtyping.cpp')
-rw-r--r-- | src/passes/LocalSubtyping.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/passes/LocalSubtyping.cpp b/src/passes/LocalSubtyping.cpp index f435e53d4..9c6da1131 100644 --- a/src/passes/LocalSubtyping.cpp +++ b/src/passes/LocalSubtyping.cpp @@ -103,14 +103,21 @@ struct LocalSubtyping : public WalkerPass<PostWalker<LocalSubtyping>> { assert(newType != Type::none); // in valid wasm there must be a LUB // Remove non-nullability if we disallow that in locals. - if (!getModule()->features.hasGCNNLocals() && newType.isNonNullable()) { - newType = Type(newType.getHeapType(), Nullable); - // Note that the old type must have been nullable as well, as non- - // nullable types cannot be locals without that feature being enabled, - // which means that we will not have to do any extra work to handle - // non-nullability if we update the type: we are just updating the - // heap type, and leaving the type nullable as it was. - assert(oldType.isNullable()); + if (newType.isNonNullable()) { + if (!getModule()->features.hasGCNNLocals()) { + newType = Type(newType.getHeapType(), Nullable); + // Note that the old type must have been nullable as well, as non- + // nullable types cannot be locals without that feature being + // enabled, which means that we will not have to do any extra work + // to handle non-nullability if we update the type: we are just + // updating the heap type, and leaving the type nullable as it was. + assert(oldType.isNullable()); + } + } else if (!newType.isDefaultable()) { + // Aside from the case we just handled of allowed non-nullability, we + // cannot put anything else in a local that does not have a default + // value. + continue; } if (newType != oldType) { |