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

Compiler crash referencing invalid this-dot reference in trait. #1878

Closed SeanTAllen closed 7 years ago

SeanTAllen commented 7 years ago

This was reported via IRC. You can see it in action at:

http://pony-playpen.lietar.net/?gist=9f9c5a11c938dd277f746f8cac4b4a4c

trait TestTrait
    fun test(): String =>
        this.str

class Temp is TestTrait
    var str: String = "Pony"

actor Main
  new create(env: Env) =>
    let t: Temp = Temp
    let r: String = t.test()
    env.out.print(r)

error as reported in playground:

compiled with: llvm 3.9.1 -- cc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
src/libponyc/ast/ast.c:480: ast_id: Assertion `ast != NULL` failed.

Backtrace:
This is an optimised version of ponyc: the backtrace may be imprecise or incorrect.
Use a debug version to get more meaningful information.
  ponyc(ponyint_assert_fail+0x8f) [0x734e6f]
  ponyc(ast_id+0x31) [0x693951]
  ponyc(refer_dot+0x2f5) [0x721cc5]
  ponyc(pass_refer+0xba3) [0x7230b3]
  ponyc() [0x6df0f5]
  ponyc() [0x6df1d6]
  ponyc() [0x6df1d6]
  ponyc() [0x6df1d6]
  ponyc() [0x6df1d6]
  ponyc() [0x6df1d6]
  ponyc() [0x6df1d6]
  ponyc() [0x6df1d6]
  ponyc() [0x6df387]
  ponyc(ast_passes_program+0x217) [0x6df947]
  ponyc(program_load+0x74) [0x6e4564]
  ponyc() [0x679199]
  ponyc(main+0x462) [0x6195e2]
  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f8318ec2830]
  ponyc(_start+0x29) [0x6790a9]
Aborted (core dumped)
funkybob commented 7 years ago

I'm getting the same error, with the following output:

$ ~/src/git/ponyc/build/release/ponyc -v
0.13.2-888080912 [release]
compiled with: llvm 3.9.1 -- cc (Debian 6.3.0-14) 6.3.0 20170415

$ ~/src/git/ponyc/build/release/ponyc -pic
Building builtin -> /home/curtis/src/git/ponyc/packages/builtin
Building . -> /home/curtis/src/kt
Building net -> /home/curtis/src/git/ponyc/packages/net
Building ponytest -> /home/curtis/src/git/ponyc/packages/ponytest
Building time -> /home/curtis/src/git/ponyc/packages/time
Building collections -> /home/curtis/src/git/ponyc/packages/collections
Building collections/persistent -> /home/curtis/src/git/ponyc/packages/collections/persistent
Building random -> /home/curtis/src/git/ponyc/packages/random
src/libponyc/ast/ast.c:480: ast_id: Assertion `ast != NULL` failed.

Backtrace:
  /home/curtis/src/git/ponyc/build/release/ponyc(ponyint_assert_fail+0x72) [0x555cb3c600c2]
  /home/curtis/src/git/ponyc/build/release/ponyc(ast_id+0x37) [0x555cb3bbd9f7]
  /home/curtis/src/git/ponyc/build/release/ponyc(lookup+0x25) [0x555cb3c486e5]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0xc30fa) [0x555cb3c510fa]
  /home/curtis/src/git/ponyc/build/release/ponyc(expr_case+0x13b) [0x555cb3c5195b]
  /home/curtis/src/git/ponyc/build/release/ponyc(pass_expr+0x15b) [0x555cb3c34fcb]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1eefa) [0x555cb3bacefa]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1ef8f) [0x555cb3bacf8f]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1ef8f) [0x555cb3bacf8f]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1ef8f) [0x555cb3bacf8f]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1ef8f) [0x555cb3bacf8f]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1ef8f) [0x555cb3bacf8f]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1ef8f) [0x555cb3bacf8f]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1ef8f) [0x555cb3bacf8f]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1ef8f) [0x555cb3bacf8f]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1ef8f) [0x555cb3bacf8f]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1f147) [0x555cb3bad147]
  /home/curtis/src/git/ponyc/build/release/ponyc(ast_passes_program+0x243) [0x555cb3bad9a3]
  /home/curtis/src/git/ponyc/build/release/ponyc(program_load+0x76) [0x555cb3bfa8f6]
  /home/curtis/src/git/ponyc/build/release/ponyc(+0x1ec88) [0x555cb3bacc88]
  /home/curtis/src/git/ponyc/build/release/ponyc(main+0x48d) [0x555cb3bac8dd]
  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x7f467062a2b1]
  /home/curtis/src/git/ponyc/build/release/ponyc(_start+0x2a) [0x555cb3bacb6a]
This is an optimised version of ponyc: the backtrace may be imprecise or incorrect.
Use a debug version to get more meaningful information.
Aborted

Haven't had a chance to whittle down the code yet, but source available upon request. Figured I'd contribute the more detailed traceback.

jemc commented 7 years ago

I've filed #1879 to fix this issue.

@funkybob your paste is actually not a more detailed traceback for this bug - it's a traceback for a totally different bug. Luckily I got you to paste your source code that triggers it in IRC. I'll open a new ticket for that distinct bug.