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

Case in match expression set unnecessary parenthesis causes SIGSEGV #79

Closed
sblessing opened this issue Nov 17, 2014 · 1 comment
Closed

Comments

@sblessing
Copy link
Contributor

The following code causes a compiler crash, where the case in the match expression is unnecessarily surrounded by parenthesis:

type Alias is ((Object, Object) | String)

class Object

actor Main
  var tuple: Alias

  new create(env: Env) =>
    tuple = ""

    match tuple
    | (var leaf: String) => env.stdout.print("Leaf!")
    end
frame #4: 0x000000010001c529 ponyc`gen_pattern_eq(c=0x00007fff5fbff608, pattern=0x0000000103e30890, r_value=0x0000000107f7c168) + 633 at gencall.c:385
   382    args[0] = l_value;
   383    args[1] = r_value;
   384  
-> 385    return codegen_call(c, func, args, 2);
   386  }
   387  
   388  LLVMValueRef gen_ffi(compile_t* c, ast_t* ast)
(lldb) p ast_print(ast_parent(pattern))
(tuple
  (seq
    (var
      (idseq ((id leaf) [nominal (id $1) (id String) x val x x]) [nominal (id $1) (id String) x val x x])
      (nominal (id $1) (id String) x val x x)
      [nominal (id $1) (id String) x val x x]
    )
    [nominal (id $1) (id String) x val x x]
  )
  [nominal (id $1) (id String) x val x x]
)
frame #3: 0x000000010001975f ponyc`codegen_call(c=0x00007fff5fbff608, fun=0x0000000106f096c0, args=0x00007fff5fbfebc0, count=2) + 63 at codegen.c:1013
   1010 LLVMValueRef codegen_call(compile_t* c, LLVMValueRef fun, LLVMValueRef* args,
   1011   size_t count)
   1012 {
-> 1013   LLVMValueRef result = LLVMBuildCall(c->builder, fun, args, (int)count, "");
   1014   LLVMSetInstructionCallConv(result, GEN_CALLCONV);
   1015   return result;
   1016 }

Whereas removing the parenthesis around "var leaf: String" makes the code compile.

type Alias is ((Object, Object) | String)

class Object

actor Main
  var tuple: Alias

  new create(env: Env) =>
    tuple = ""

    match tuple
    | var leaf: String => env.stdout.print("Leaf!")
    end
@sblessing sblessing added the bug label Nov 17, 2014
sylvanc added a commit that referenced this issue Nov 17, 2014
@sylvanc
Copy link
Contributor

sylvanc commented Nov 17, 2014

Fixed.

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

No branches or pull requests

2 participants