ponylang/ponyc

Invalid LLVM generated

SeanTAllen opened this issue · 1 comments

class Foo
  new create(a: U32) ? =>
    error

actor Main
  new create(env: Env) =>
    try
      let f = Foo(1)?
    end

Results in:

Terminator found in the middle of a basic block!
label %entry
Error:
Module verification failed: Terminator found in the middle of a basic block!
label %entry

I think the most reasonable thing for this given that

class Foo
  new create(a: U32) ? =>
    if a > 10 then
      error
    end
    
actor Main
  new create(env: Env) =>
    try
      let f = Foo(1)?
    end

is valid code, is to verify that a constructor can actually construct an object given some path through it. That is the assumption that I believe leads to the bad LLVM. We should be catching the "this can only error" and reporting back as that as something that needs to be fixed.