ark-lang / ark

A compiled systems programming language written in Go using the LLVM framework
https://ark-lang.github.io/
MIT License
682 stars 47 forks source link

Panic when calling non-existent method on inferred instance #693

Closed felixangell closed 8 years ago

felixangell commented 8 years ago
ark build -I lib/std lib/tests/test-fileio.ark 
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x10 pc=0x754417]

goroutine 1 [running]:
github.com/ark-lang/ark/src/parser.SubsType(0xc820243770, 0x6, 0xc8201ce750, 0xc820243860)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/parser/inference.go:217 +0x10d7
github.com/ark-lang/ark/src/parser.Side.Subs(0x1, 0x0, 0xc820243770, 0x6, 0x1, 0x0, 0xc8201ce750, 0x0, 0x0, 0x0)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/parser/inference.go:166 +0xcb
github.com/ark-lang/ark/src/parser.(*Constraint).Subs(0xc8202437a0, 0x6, 0x1, 0x0, 0xc8201ce750, 0xc820243890)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/parser/inference.go:119 +0x102
github.com/ark-lang/ark/src/parser.(*Inferrer).SolveStep.func1(0x6, 0x1, 0x0, 0xc8201ce750)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/parser/inference.go:917 +0xbb
github.com/ark-lang/ark/src/parser.(*Inferrer).SolveStep(0xc8201c6d90, 0xc8201db620, 0x3, 0x3, 0x0, 0x0, 0x0, 0x0, 0xc8202431a0, 0xc8201db620, ...)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/parser/inference.go:934 +0x1e8
github.com/ark-lang/ark/src/parser.(*Inferrer).Solve(0xc8201c6d90, 0x0, 0x0, 0x0)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/parser/inference.go:894 +0x1c2
github.com/ark-lang/ark/src/parser.(*Inferrer).Finalize(0xc8201c6d90)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/parser/inference.go:1056 +0x82
github.com/ark-lang/ark/src/parser.Infer.func1()
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/parser/inference.go:409 +0x187
github.com/ark-lang/ark/src/util/log.Timed(0x1e5f890, 0x13, 0xc82021d650, 0xc, 0xc82021d7f8)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/util/log/timed.go:28 +0x2f8
github.com/ark-lang/ark/src/parser.Infer(0xc8201b8280)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/parser/inference.go:410 +0x1ab
main.build.func2()
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/cmd/ark/main.go:252 +0x118
github.com/ark-lang/ark/src/util/log.Timed(0x1e1a620, 0xf, 0x0, 0x0, 0xc82021ddd0)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/util/log/timed.go:28 +0x2f8
main.build(0xc820114640, 0x1, 0x1, 0x1e0b818, 0x4, 0x1e0b590, 0x4, 0x3, 0x0)
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/cmd/ark/main.go:262 +0x26d
main.main()
    /home/felix/dev/go/src/github.com/ark-lang/ark/src/cmd/ark/main.go:45 +0x2aa

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/lib/go/src/runtime/asm_amd64.s:1721 +0x1

Caused by the following:

#use mem
#use io

pub func main() -> int {
    myFilePath := io::Path::new("test.ark");

    myFilePath.close();
    return 0;
}

Note that path actually doesn't have a close method, though this is likely irrelevant since it's an inference error.