onyx-lang / onyx

✨ The compiler and developer toolchain for Onyx
https://onyxlang.io
BSD 2-Clause "Simplified" License
576 stars 22 forks source link

Quick procedures with captures do not have return types inferred correctly #144

Open brendanfh opened 7 months ago

brendanfh commented 7 months ago
x := 10

f := ([x]) => x

g :: (f: () -> $R) -> R {
    return f()
}

g(f) |> println() // Should return 10
error: Error solving for polymorphic variable 'R'.
   at: /home/brendan/dev/onyx/asdf.onyx:8,10
   |
 8 |     g :: (f: () -> $R) -> R {
   |          ^
error: Unable to solve for polymorphic variable 'R', given the type '() -> unknown'.
   at: /home/brendan/dev/onyx/asdf.onyx:8,21
   |
 8 |     g :: (f: () -> $R) -> R {
   |                     ^
error: Here is where the call is located.
   at: /home/brendan/dev/onyx/asdf.onyx:12,6
    |
 12 |     g(f) |> println() // Should return 10
    |      ^