[Gambas-user] Cute compiler bug

Tobias Boege taboege at ...626...
Sat May 3 22:38:13 CEST 2014


Hi Benoit,

the compiler seems to ignore "As something" annotations on the LHS of an
assignment. I called them "annotations" but actually I couldn't find any
mention of such a construct in the grammar of expression assignment or LHS
published in the wiki. Look at that code:

  Dim aLetters As String[] = ["a", "b", "c"] ' (1)

  aLetters As String[] = ["d", "e", "f"]     ' (2)
  aLetters As FMain = ["g", "h", "i"]        ' (3)

In (1), it's totally OK, because "As String[]" is part of the Dim. In (2)
it's strange but it works. aLetters is not redeclared or anything but only
assigned a value. The "As String[]" happens to do nothing but like remind
the programmer of the type of aLetters.

In (3) it gets totally absurd :-) But it works as if there was nothing. It
should, IMO, raise a compiler error - not because it does nothing or looks
weird but because it is not part of the grammar, apparently.

I have only found this working in the LHS of an assignment which *includes*
"operating assignments" like +=, &=, etc.. I will definitely have a great
time with that until it gets fixed :-)

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list