ponyc icon indicating copy to clipboard operation
ponyc copied to clipboard

Attempting to partially apply a constructor causes a crash in ponyc

Open chalcolith opened this issue 9 months ago • 1 comments

The following program (playground link) causes a crash in the compiler:

class A
  let n: USize

  new create(n': USize) =>
    n = n'

actor Main
  new create(env: Env) =>
    let a1 = A(1)
    let ctor = A~create(2)
    let a: A = ctor()

The backtrace is:

/home/gordon/Dev/Pony/ponyc_main/src/libponyc/codegen/genexpr.c:314: gen_assign_cast: Assertion `r_value != GEN_NOTNEEDED` failed.

Backtrace:
  ../../../build/debug/ponyc(ponyint_assert_fail+0x8f) [0x5606be9f621f]
  ../../../build/debug/ponyc(gen_assign_cast+0x5c) [0x5606be91892c]
  ../../../build/debug/ponyc(gen_call+0x678) [0x5606be911808]
  ../../../build/debug/ponyc(gen_expr+0x1b4) [0x5606be918564]
  ../../../build/debug/ponyc(gen_assign+0x47) [0x5606be923777]
  ../../../build/debug/ponyc(gen_expr+0x30d) [0x5606be9186bd]
  ../../../build/debug/ponyc(gen_seq+0x49) [0x5606be9ca479]
  ../../../build/debug/ponyc(gen_expr+0x72) [0x5606be918422]
  ../../../build/debug/ponyc(+0x6eed05) [0x5606be91ad05]
  ../../../build/debug/ponyc(+0x6edfe5) [0x5606be919fe5]
  ../../../build/debug/ponyc(genfun_method_bodies+0x8f) [0x5606be919e5f]
  ../../../build/debug/ponyc(gentypes+0x332) [0x5606be9323f2]
  ../../../build/debug/ponyc(genexe+0x2a6) [0x5606be917ac6]
  ../../../build/debug/ponyc(codegen+0xc9) [0x5606be90cbd9]
  ../../../build/debug/ponyc(generate_passes+0x2c) [0x5606be95ff8c]
  ../../../build/debug/ponyc(+0x6d58cc) [0x5606be9018cc]
  ../../../build/debug/ponyc(main+0x243) [0x5606be901723]
  /lib/x86_64-linux-gnu/libc.so.6(+0x2a1ca) [0x7f75368931ca]
  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x8b) [0x7f753689328b]
  ../../../build/debug/ponyc(_start+0x25) [0x5606be901415]
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Aborted (core dumped)

Not sure why an LLVM warning is showing up in there, as this is an assert in ponyc code.

chalcolith avatar Feb 12 '25 19:02 chalcolith