From 8d0b995f07d14e03c5477b8ac361e699ecc20a54 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sat, 31 Mar 2018 03:10:49 +0200 Subject: [PATCH] Accept library function names as vars in simple_expr in globals This may cause more trouble than it's worth, but it's how LSL behaves and one of our objectives is to document the darker corners of LSL. Mono chokes at the RAIL postprocessing stage, not in compilation proper. LSO chokes at runtime for string, key and list, and works fine for the other types. --- lslopt/lslparse.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lslopt/lslparse.py b/lslopt/lslparse.py index 51a7652..0f82e2a 100644 --- a/lslopt/lslparse.py +++ b/lslopt/lslparse.py @@ -2222,7 +2222,10 @@ list lazy_list_set(list L, integer i, list v) value=val) if tok[0] == 'IDENT': sym = self.FindSymbolPartial(tok[1]) - if sym is None or sym['Kind'] != 'v': + # The parser accepts library function names here as valid variables + # (it chokes at RAIL in Mono, and at runtime in LSO for some types) + if sym is None or sym['Kind'] != 'v' and (sym['Kind'] != 'f' + or 'ParamNames' in sym): # only UDFs have ParamNames raise EParseUndefined(self) typ = sym['Type'] if ForbidList and lslcommon.LSO and typ == 'key': @@ -2230,7 +2233,8 @@ list lazy_list_set(list L, integer i, list v) # var inside a list global definition takes a string value # (SCR-295). typ = 'string' - return nr(nt='IDENT', t=typ, name=tok[1], scope=sym['Scope']) + return nr(nt='IDENT', t=typ, name=tok[1], + scope=sym['Scope'] if sym['Kind'] == 'v' else 0) if tok[0] == '<': value = [self.Parse_simple_expr()] self.autocastcheck(value[0], 'float')