koka-lang / koka

Koka language compiler and interpreter
http://koka-lang.org
Other
3.16k stars 151 forks source link

Memory Leak using VSCode with koka v3.0.1 for macos-arm64 #449

Closed louy2 closed 5 months ago

louy2 commented 5 months ago

Trying to learn koka but this is preventing me completely.

With koka v3.0.1 for macos-arm64, and this code:

fun test_03_if1()
  val bigger = fn(x, y) if y < x then x else y
  bigger(1, 2).show.println

Hover to get signature hangs at "Loading..." and koka-v3.0.1 quickly grows to use >20GB of memory, slowing down the entire machine.

chtenb commented 5 months ago

Possibly related https://github.com/koka-lang/koka/issues/438

louy2 commented 5 months ago

If this is 438, what causes the extension to trigger an infinite loop of reloads then? A simple hello world is spared from this leaking behavior.

TimWhiting commented 5 months ago

Actually this is related to the typechecking bug: #446 , #437. The problem is that y < x looks for a compare signature that is fully polymorphic, which causes an infinite loop.

For now you can fix it by doing this

fun test_03_if1()
  val bigger = fn(x:int, y:int) if y < x then x else y
  bigger(1, 2).show.println

On the dev branch the root cause of the infinite loop is fixed. (As is mentioned in the linked issues). Maybe I can get Daan to release a version quickly with the fix, since it is showing up in a lot of issues.

However, I do know that he is currently revamping the Module system / compilation pipeline which should hopefully make progress on #438, and allow us to build modules in parallel & surface errors from all files in the workspace for the language server, here is the issue to track for that work though he'll probably deviate from my proposal a bit #432.