Closed Bug 1787444 Opened 4 years ago Closed 4 years ago

Don't generate union conversion code in its own scope if it has been put in a if-else scope

Categories

(Core :: DOM: Bindings (WebIDL), enhancement)

enhancement

Tracking

()

RESOLVED DUPLICATE of bug 1784266

People

(Reporter: edgar, Assigned: edgar)

Details

Attachments

(1 file, 2 obsolete files)

For example,

https://searchfox.org/mozilla-central/source/__GENERATED__/dom/bindings/TestExampleGenBinding.cpp#28573-28595

if (!(args.hasDefined(0)) || args[0].isNullOrUndefined()) {
  arg0.SetNull();
} else {
  arg0_holder.emplace(arg0.SetValue());
  {
    bool done = false, failed = false, tryNext;
    do {
      if (args[0].isNumber()) {
        done = (failed = !arg0_holder.ref().TrySetToDouble(cx, args[0], tryNext)) || !tryNext;
        break;
      }
      done = (failed = !arg0_holder.ref().TrySetToUTF8String(cx, args[0], tryNext)) || !tryNext;
      break;
    } while (false);
    if (failed) {
      return false;
    }
    if (!done) {
      cx.ThrowErrorMessage<MSG_NOT_IN_UNION>("Argument 1", "");
      return false;
    }
  }
}

Found this while working on bug 1784266, and realize it might be better to address this in a separated bug.

Attached patch binging_diff_D155694.patch (obsolete) — — Splinter Review
Attachment #9291744 - Attachment is obsolete: true
Attachment #9291743 - Attachment is obsolete: true

https://phabricator.services.mozilla.com/D156176 will also remove unnecessary { } scope.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: