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

with tuple causes compiler to abort #3581

Closed
anacrolix opened this issue Jun 29, 2020 · 1 comment · Fixed by #3586
Closed

with tuple causes compiler to abort #3581

anacrolix opened this issue Jun 29, 2020 · 1 comment · Fixed by #3586

Comments

@anacrolix
Copy link

The following code causes the compiler to abort:

actor Main
  new create(env: Env) =>
    with (a,b) = (1,2) do
      None
    end

I think it's the (a,b) on the LHS. The output:

$ ~/src/ponyc/build/debug/ponyc 
Building builtin -> /Users/anacrolix/src/ponyc/packages/builtin
Building . -> /Users/anacrolix/src/mylittle/with-abort
/Users/anacrolix/src/ponyc/src/libponyc/pass/sugar.c:542: build_with_dispose: Assertion `ast_id(idseq) == TK_TUPLE` failed.

Backtrace functionality not available.
Abort trap: 6
@mfelsche mfelsche added the bug label Jun 29, 2020
@mfelsche
Copy link
Contributor

This is clearly a bug. Though, strictly speaking, (a, b) needs to have a dispose function or behaviour for this to fully compile, and a tuple doesnt have such a function. On the other hand it is clear that tuple destructuring should work inside a with-expression, so a and b should have a dispose method or behaviour.

Also there is also no test coverage yet for tuple destructuring in with expressions.

The bug is in https://github.com/ponylang/ponyc/blob/master/src/libponyc/pass/sugar.c#L542 when the left side of the with-expression is a tuple, it calls itself recursively with the AST-child of that tuple, expecting a let or another tuple. But the child of the given tuple AST is a TK_SEQ (a list of things) of let expressions (for a and b in the case above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants