Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/wast-parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3439,7 +3439,11 @@ Result WastParser::ParseModuleCommand(Script* script, CommandPtr* out_command) {
error.loc.offset, error.message.c_str());
}
}
*module = std::move(*m.get());
if (m) {
*module = std::move(*m.get());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for ParseWatModule above to succeed without *m being set?

Would this work instead:

if (errors.length()) { 
  return Result::Error;
}
assert(*m);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't ParseWatModule also return a Result? probably a good idea to check that instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that sounds good. You can do something like this

if (Failed(ParseWatModule(lexer.get(), &m, &errors, options_)) { 
   for (const auto& error : errors) {
      ...
   }
   return Result::Error;
}
assert(errors.length == 0);

} else {
return Result::Error; // Handle the null case appropriately
}
*out_command = std::move(command);
break;
}
Expand Down
Loading