diff options
-rw-r--r-- | src/resolve-names.cc | 1 | ||||
-rw-r--r-- | src/wast-parser.cc | 14 | ||||
-rw-r--r-- | test/parse/expr/bulk-memory-named.txt | 2 | ||||
-rw-r--r-- | test/parse/module/bad-elem-redefinition.txt | 13 |
4 files changed, 26 insertions, 4 deletions
diff --git a/src/resolve-names.cc b/src/resolve-names.cc index 1bcc52e6..0e3c70e1 100644 --- a/src/resolve-names.cc +++ b/src/resolve-names.cc @@ -461,6 +461,7 @@ void NameResolver::VisitDataSegment(DataSegment* segment) { Result NameResolver::VisitModule(Module* module) { current_module_ = module; + CheckDuplicateBindings(&module->elem_segment_bindings, "elem"); CheckDuplicateBindings(&module->func_bindings, "function"); CheckDuplicateBindings(&module->global_bindings, "global"); CheckDuplicateBindings(&module->func_type_bindings, "function type"); diff --git a/src/wast-parser.cc b/src/wast-parser.cc index 517b70bc..ca21584f 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -932,9 +932,17 @@ Result WastParser::ParseElemModuleField(Module* module) { EXPECT(Lpar); Location loc = GetLocation(); EXPECT(Elem); - std::string name; - ParseBindVarOpt(&name); - auto field = MakeUnique<ElemSegmentModuleField>(loc, name); + std::string segment_name; + ParseBindVarOpt(&segment_name); + // With MVP text format the name here was intended to refer to the table + // that the elem segment was part of, but we never did anything with this name + // since there was only one table anyway. + // With bulk-memory enabled this introduces a new name for the particualr + // elem segment. + if (!options_->features.bulk_memory_enabled()) { + segment_name = ""; + } + auto field = MakeUnique<ElemSegmentModuleField>(loc, segment_name); if (ParseRefTypeOpt(&field->elem_segment.elem_type)) { field->elem_segment.passive = true; diff --git a/test/parse/expr/bulk-memory-named.txt b/test/parse/expr/bulk-memory-named.txt index 22a94d2f..92af32d3 100644 --- a/test/parse/expr/bulk-memory-named.txt +++ b/test/parse/expr/bulk-memory-named.txt @@ -11,7 +11,7 @@ (table 1 anyfunc) (elem $elem funcref (ref.func 0) (ref.null)) - (elem $elem funcref 0) + (elem $elem2 funcref 0) (func i32.const 0 i32.const 0 i32.const 0 table.init $elem elem.drop $elem diff --git a/test/parse/module/bad-elem-redefinition.txt b/test/parse/module/bad-elem-redefinition.txt new file mode 100644 index 00000000..1b589617 --- /dev/null +++ b/test/parse/module/bad-elem-redefinition.txt @@ -0,0 +1,13 @@ +;;; TOOL: wat2wasm +;;; ARGS: --enable-bulk-memory +;;; ERROR: 1 +(module + (elem $elem funcref 0) + (elem $elem funcref 0) + (func)) + +(;; STDERR ;;; +out/test/parse/module/bad-elem-redefinition.txt:6:4: error: redefinition of elem "$elem" + (elem $elem funcref 0) + ^^^^ +;;; STDERR ;;) |