[Gambas-user] Cute compiler bug
Benoît Minisini
gambas at ...1...
Tue May 6 22:10:07 CEST 2014
Le 03/05/2014 22:38, Tobias Boege a écrit :
> 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
>
It should be fixed in revision #6253.
Regards,
--
Benoît Minisini
More information about the User
mailing list