ponylang / ponyc

Pony is an open-source, actor-model, capabilities-secure, high performance programming language
http://www.ponylang.io
BSD 2-Clause "Simplified" License
5.68k stars 409 forks source link

Infinite Recursion in compiler #2399

Open Theodus opened 6 years ago

Theodus commented 6 years ago

Pony code:

interface val X[Y: X[Y]]
  fun apply(y: X[Y]) // Compiles if this is commented

type C is ((A | B) & X[(A | B)]) // Also compiles if the `& X[(A | B)]` is omitted

primitive A is X[C]
  fun apply(y: X[C]) => None

primitive B is X[C]
  fun apply(y: X[C]) => None

Ponyc version:

0.20.0-883d1ce8 [debug]
compiled with: llvm 3.9.1 -- clang version 5.0.0 (tags/RELEASE_500/final)

Compiler output:

Building builtin -> /home/theodus/src/ponylang/ponyc/packages/builtin
Building . -> /home/theodus/src/theodus/fsm/wat
Segmentation fault

LLDB Backtrace:

(lldb) run
Process 19043 launched: '/home/theodus/src/ponylang/ponyc/build/debug/ponyc' (x86_64)
Building builtin -> /home/theodus/src/ponylang/ponyc/packages/builtin
Building . -> /home/theodus/src/theodus/fsm/wat
Process 19043 stopped
* thread #1, name = 'ponyc', stop reason = signal SIGSEGV: invalid address (fault address: 0x7fffff7feff8)
    frame #0: 0x00000000006fc388 ponyc`ast_child(ast=<unavailable>) at ast.c:972
   969  }
   970  
   971  ast_t* ast_child(ast_t* ast)
-> 972  {
   973    pony_assert(ast != NULL);
   974    return ast->child;
   975  }

Very long backtrace: lldb_out.txt

jemc commented 6 years ago

I think there may already be a similar open issue ticket to this one, but I'm not sure where it is.

jemc commented 6 years ago

This might be a more minimal reproduction of the same issue, or it may just be a different but similar issue:

interface I[A]
  fun subset[B: (A & Any #share)](): I[B] =>
    Subset[A, B]

class Subset[A, B: (A & Any #share)] is I[B]