For normal struct UDTs all identifiers are allowed including core keywords and quirk keywords, although due to the parsing ambiguity, if you want the parser to treat something as field identifier, you sometimes have to use the "AS TYPE id" multiple-declaration syntax instead of the normal "id AS TYPE" single-declaration one.
Code: Select all
'dim as integer '' Parsed as DIM declaration, so the DIM is not the identifier
as integer dim '' but this works, DIM is the identifier
'' ditto... we can even have a field called "as"
as integer declare, static, as
'' works thanks to the parser doing a look-ahead and finding the AS,
'' indicating a field called "union" instead of a UNION block
union as integer
dim x as UDT
print x.dim, x.declare, x.static, x.as, x.union
In class UDTs, core keywords are not allowed as field names (probably due to parsing difficulties thanks to the implicit THIS field accesses from within method bodies), however quirk keywords are still allowed.
The few operator keywords (AND, OR, SHL, ...) are forbidden in both cases, although I think that wouldn't be necessary at least for struct UDTs.
For reference: src/compiler/symb-keyword.bas(27)