Skip to content

Commit

Permalink
Fix conditional expression returns the same value in jsinterp
Browse files Browse the repository at this point in the history
force-test skip-release
  • Loading branch information
Taapat committed Aug 30, 2023
1 parent 54ab2c4 commit 61d075d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/jsinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,14 @@ def interpret_statement(self, stmt, local_vars, allow_recursion=100):
# try for object expression (Map)
sub_expressions = [list(self._separate(sub_expr.strip(), ':', 1)) for sub_expr in self._separate(inner)]
if all(len(sub_expr) == 2 for sub_expr in sub_expressions):
return dict(
(key_expr if re.match(_NAME_RE, key_expr) else key_expr,
self.interpret_expression(val_expr, local_vars, allow_recursion))
for key_expr, val_expr in sub_expressions), should_return
# or statement list
def dict_item(key, val):
val = self.interpret_expression(val, local_vars, allow_recursion)
if re.match(_NAME_RE, key):
return key, val
return self.interpret_expression(key, local_vars, allow_recursion), val

return dict(dict_item(k, v) for k, v in sub_expressions), should_return

inner, should_abort = self.interpret_statement(inner, local_vars, allow_recursion)
if not outer or should_abort:
return inner, should_abort or should_return
Expand Down

0 comments on commit 61d075d

Please sign in to comment.