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.73k stars 415 forks source link

Compiler segfault when using generics #2562

Open lukecheeseman opened 6 years ago

lukecheeseman commented 6 years ago
trait X[A: X[A] box]
  fun apply[B: X[B] box](a: B) =>
    None

  fun f() =>
    apply[X[A]](this)

class C is X[C box]

I was looking at @Praetonus's F-Bounded Polymorphism issue and tweaked the input a bit and hit a segfault. I'm not sure if this is related to other bugs with generics that I can see on the issues list so thought I would raise it just in case.

Praetonus commented 6 years ago

This is an infinite loop in the subtype checking code. The compiler is stuck trying to determine whether X[A] box is a subtype of X[A] ref. This happens when checking the generic constraints of the call to X.apply in X.f.

Praetonus commented 6 years ago

This looks like a duplicate of #2399. I'm going to leave both issues open since the code example here is simpler.