From 0122d6ed70fd17e00142bfc16b11f90f1690fdc3 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Fri, 4 Sep 2015 06:26:01 +0200 Subject: [PATCH] On second thought, disable explicitcast for list+nonlist and nonlist+list entirely, as they are not the same as list+(list)nonlist and (list)nonlist+list anyway. --- lslopt/lslparse.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lslopt/lslparse.py b/lslopt/lslparse.py index 4bf6124..0f0e3b4 100644 --- a/lslopt/lslparse.py +++ b/lslopt/lslparse.py @@ -1125,18 +1125,13 @@ list lazy_list_set(list L, integer i, list v) if ltype == rtype == 'key': # key + key is the only disallowed combo of equals raise EParseTypeMismatch(self) - if self.explicitcast: - if ltype == 'list' != rtype: - rexpr = {'nt':'CAST', 't':ltype, 'ch':[rexpr]} - elif rtype == 'list' != ltype: - term = {'nt':'CAST', 't':rtype, 'ch':[term]} + # Note that although list + nonlist is semantically the + # same as list + (list)nonlist, and similarly for + # nonlist + list, they don't compile to the same thing, + # so we don't act on self.explicitcast in this case. if rtype == 'list': ltype = rtype term = {'nt':op, 't':ltype, 'ch':[term, rexpr]} - # Note that although list + nonlist is semantically the same as - # list + (list)nonlist and same goes for nonlist + list, they - # don't compile to the same thing, but the optimizer should deal - # with typecast removal anyway. elif self.allowkeyconcat and op == '+' \ and ltype in ('key', 'string') and rtype in ('key', 'string'): # Allow string+key addition (but add explicit cast)