Problem using REF NULL as parameter
Following reports "A REF or OUT value must be an assignable variable" on using REF NULL. But using OUT NULL in the line above works without errors. So either both must be accepted without errors, or the error message needs to be adjusted to not include "OUT"
FUNCTION Start() AS VOID
LOCAL n := 0 AS INT
ProcOut(OUT n, OUT NULL) // no error
ProcRef(REF n, REF NULL) // error XS1510: A REF or OUT value must be an assignable variable
PROCEDURE ProcRef(n REF INT, m REF INT)
PROCEDURE ProcOut(n OUT INT, m OUT INT)
n := 1; m := 2
OUT NULL works because we have added a special rule in the parser in the namedArgument rule:
// NOTE: Expression is optional so we can skip arguments for VO/Vulcan compatibility
namedArgument : {AllowNamedArgs}? Name=identifierName Op=ASSIGN_OP ( RefOut=(REF | OUT) )? Expr=expression
| RefOut=OUT Var=VAR Id=varidentifier
| RefOut=OUT Id=varidentifier AS Type=datatype
| RefOut=OUT Null=NULL
| ( RefOut=(REF | OUT) )? Expr=expression?
;
I was looking for the argument discard operator "_" that c# has, thought this was our version with NULL. Or do we support "_" with a different syntax?
We support "_" too.
What's the syntax for it? Couldn't make it work...
ProcOut( OUT VAR _, OUT VAR _)
Thanks, only thing I didn't try!
When I tried it also with REF, got parser errors, see below. I assume they are only allowed for OUT, but if possible would be nice to allow with REF as well, because almost everybody is (unfortunately) only using REF - I will talk about this in my session.
In any case, the error messages in both cases (NULL and _) need some improvement.
FUNCTION Start() AS VOID
LOCAL n := 0 AS INT
ProcOut(OUT n, OUT VAR _) // no error
// error XS9002: Parser: unexpected input '_'
// error XS9065: Assignment operator ':=' expected.
ProcRef(REF n, REF VAR _)
PROCEDURE ProcRef(n REF INT, m REF INT)
PROCEDURE ProcOut(n OUT INT, m OUT INT)
n := 1; m := 2
REF VAR does not make sense. The Ref variable needs to have a value before it is used. The discard variable (that is the official name for _ ) is not initialized.