Skip to content

Commit

Permalink
Fix breakage in last commit.
Browse files Browse the repository at this point in the history
spec/array.test.sh caught it.
  • Loading branch information
Andy Chu committed Sep 28, 2018
1 parent f1a54e5 commit f3d9c30
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/word_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,14 +521,20 @@ def _EvalBracedVarSub(self, part, part_vals, quoted):
elif val.tag == value_e.StrArray:
index = self.arith_ev.Eval(anode)
try:
val = runtime.Str(val.strs[index])
# could be None because representation is sparse
s = val.strs[index]
except IndexError:
s = None

if s is None:
val = runtime.Undef()
else:
val = runtime.Str(s)

elif val.tag == value_e.AssocArray:
key = self.arith_ev.Eval(anode, int_coerce=False)
try:
s = runtime.Str(val.d[key])
val = runtime.Str(val.d[key])
except KeyError:
val = runtime.Undef()

Expand Down

0 comments on commit f3d9c30

Please sign in to comment.