diff --git a/frontend/location.py b/frontend/location.py index 4e3c75c76a..b538382170 100644 --- a/frontend/location.py +++ b/frontend/location.py @@ -13,7 +13,7 @@ command__DoGroup, command__BraceGroup, command__Subshell, command__WhileUntil, command__If, command__Case, command__TimeBlock, - arith_expr_e, arith_expr_t, arith_expr__ArithWord, + arith_expr_e, arith_expr_t, arith_expr__ArithWord, arith_expr__VarRef ) from asdl import runtime from core.util import log @@ -70,8 +70,8 @@ def SpanForArithExpr(node): UP_node = node with tagswitch(node) as case: if case(arith_expr_e.VarRef): - # TODO: VarRef should store a token instead of a string! - return runtime.NO_SPID + node = cast(arith_expr__VarRef, UP_node) + return node.token.span_id elif case(arith_expr_e.ArithWord): node = cast(arith_expr__ArithWord, UP_node) return word_.LeftMostSpanForWord(node.w) diff --git a/osh/sh_expr_eval.py b/osh/sh_expr_eval.py index 4b2a9fa128..716db52ff7 100755 --- a/osh/sh_expr_eval.py +++ b/osh/sh_expr_eval.py @@ -363,7 +363,7 @@ def _ValToIntOrError(self, val, span_id=runtime.NO_SPID): elif case(value_e.Str): val = cast(value__Str, UP_val) - return _StringToInteger(val.s, span_id=span_id) # calls e_die + return _StringToInteger(val.s, span_id=span_id) # calls e_strict elif case(value_e.Obj): # Note: this handles var x = 42; echo $(( x > 2 )). @@ -377,8 +377,6 @@ def _ValToIntOrError(self, val, span_id=runtime.NO_SPID): if self.exec_opts.strict_arith(): raise else: - span_id = word_.SpanIdFromError(e) - self.errfmt.PrettyPrintError(e, prefix='warning: ') return 0 # Arrays and associative arrays always fail -- not controlled by @@ -744,7 +742,6 @@ def _StringToIntegerOrError(self, s, blame_word=None): if self.always_strict or self.exec_opts.strict_arith(): raise else: - self.errfmt.PrettyPrintError(e, prefix='warning: ') i = 0 return i