#627 Odd little bug with preincrement

KevinKelley Sat 6 Jun 2009

This test:

class test
{
  Int val := 0

  Void funk() { }

  Void main()
  {
    funk      // error here when followed by ...
    ++val     // ... this.
  }
}

gives this error:

C:\fansrc\bug6.fan(10,7): Expected expression statement
ERROR: cannot compile script

(error points to the function call; changing ++val to val += 1 makes the error go away.)

Throwing in a semicolon after funk fixes it; also changing the return type of funk to Int fixes it (which seems weird).

brian Sat 6 Jun 2009

Yeah, there are a couple cases where Fan's grammar is ambiguous regarding lack of a semicolon. Although I think we've fixed the biggest ones regarding return, (, and [ appearing on the same line as the start of their expr.

If you guys want we can do the same for the postfix operators ++ and --?

jtobler Thu 30 Jul 2009

This example deals with prefix operators, though.

Login or Signup to reply.