1

I wrote a Fantom script that defines a bunch of classes. As I could run the script successfully, I decided to convert this into a proper Fantom project, but one of the classes cannot be compiled and the error message is:

Expected expression, not '|'

The class has this form:

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

    MyType myVar := MyType()

    Void main() {
        // do more stuff
    }

}

I don't understand why the compiler complains when this class is part of a Fantom project, but doesn't if is part of a Fantom script instead. Can anyone shed some light, please?

Thank you

LightDye
  • 1,234
  • 11
  • 15

1 Answers1

1

It's a just a bad error message on Fantom's behalf. It is actually complaining that the classes Foo and Bar don't exist. Add the following to your project and all should compile okay.

class Foo {}
class Bar {}
class MyType {}
Steve Eynon
  • 4,979
  • 2
  • 30
  • 48
  • Thanks a lot Steve. You are very right! It is a bad error message. The Foo class actually exists next to MyClass, but the Bar class belongs to another pod for which I missed the "using" statement. – LightDye Jun 28 '17 at 12:00