Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dart2js cps: Variables declared in finally block #24485

Closed
asgerf opened this issue Oct 2, 2015 · 3 comments
Closed

dart2js cps: Variables declared in finally block #24485

asgerf opened this issue Oct 2, 2015 · 3 comments
Assignees

Comments

@asgerf
Copy link
Contributor

asgerf commented Oct 2, 2015

Variables declared in a finally block cause an assertion error in the CPS builder, because one variable is added to the environment multiple times.

This is the assertion that fails:

  void extend(Local element, ir.Primitive value) {
    // Assert that the name is not already in the environment.  `null` is used
    // as the name of anonymous variables.
    assert(!variable2index.containsKey(element));
    if (element != null) variable2index[element] = index2variable.length;
    index2variable.add(element);
    index2value.add(value);
  }

There are a bunch of tests that fail in checked-mode because of this; here is a minimal one:

main() {
  try {
    print("fdg");
  } finally {
    var x = 12345678;
    print(x);
  }
}

The variable may be assigned different indices because of different environment sizes at entry points to the finally. I can't see an easy fix to this short of wrapping all variable elements in a "finally element" so different copies of the variable can be distinguished.

The issue should go away when we introduce first-class finally to the IR. I'm not sure if it's worth fixing in the current form.

@kmillikin

@rakudrama
Copy link
Member

Obsolete

@lrhn
Copy link
Member

lrhn commented Feb 28, 2017

Tests are still marked as crashing with this issue number in pkg.status. Please investigate.

@lrhn lrhn reopened this Feb 28, 2017
@asgerf
Copy link
Contributor Author

asgerf commented Feb 28, 2017

The status file sections were obsolete. Fixed in 2d6c90a.

@asgerf asgerf closed this as completed Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants