#2613 Misleading compiler message

LightDye Wed 28 Jun

I have a class of this form:

class MyClass
{
  const Func myFunc := |Foo foo, Bar bar| {
    // do stuff
  }

  MyType myVar := MyType()

  Void main() {
    // do more stuff
  }
}

In this example, the class called Bar belongs to another pod but I forgot to add

using myOtherPod

so the compiler couldn't figure it out, but the error message it gave on line 3 was quite misleading as it only said:

Expected expression, not '|'

(Thanks Steve for pointing out what the actual error was: see StackOverflow)

If I removed the definition of myFunc altogether and MyType was also on the non-referenced pod, the compiler error is far more obvious:

Unknown type 'MyType'

Can the first compilation error message be improved, please?

Login or Signup to reply.