koka-lang / koka

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

Wrong error format for `Type.Infer.inferHandler: using a bare operation is deprecated` #508

Open anfelor opened 2 months ago

anfelor commented 2 months ago

Consider the following state effect and handler:

effect state<a>
  fun get() : a
  fun put(x : a) : unit

fun state(s : a, f : () -> <state<a>,div|e> b) : <div|e> b
  var st := s
  with handler
    get() { st } // notice the missing 'fun' keyword
    fun put(s') { st := s }
  f()

Since we forgot to write fun in front of get, we get an error message:

Type.Infer.inferHandler: using a bare operation is deprecated.
  hint: start with 'val', 'fun', 'brk', or 'ctl' instead.
CallStack (from HasCallStack):
  error, called at src/Common/Failure.hs:46:12 in koka-3.1.1-GrUKw6cowJ9E7PPCKFMvzQ:Common.Failure
  raise, called at src/Common/Failure.hs:32:5 in koka-3.1.1-GrUKw6cowJ9E7PPCKFMvzQ:Common.Failure
  failure, called at src/Type/Infer.hs:1105:43 in koka-3.1.1-GrUKw6cowJ9E7PPCKFMvzQ:Type.Infer

The error message itself is good and tells us how to fix the problem. However, this error message comes from a call to error and does not fit in nicely with the rest of Koka's error reporting. In particular, there is no syntax highlighting in VSCode.