~andyc/oil

38c93d0ef9a06c2ecdf4e527593f54cfe3978d88 — Andy Chu a month ago 3807f1a
[errors] Suppress stack trace in Oil expressions

A temporary fix for #977, until we can really do it right in #636

Also add a test case for == as equality
3 files changed, 47 insertions(+), 2 deletions(-)

M osh/cmd_eval.py
M spec/oil-expr.test.sh
M spec/oil-user-feedback.test.sh
M osh/cmd_eval.py => osh/cmd_eval.py +9 -1
@@ 706,7 706,15 @@ class CommandEvaluator(object):

            # Note: there's only one LHS
            vd_lval = lvalue.Named(node.lhs[0].name.val)  # type: lvalue_t
            py_val = self.expr_ev.EvalExpr(node.rhs)
            try:
              py_val = self.expr_ev.EvalExpr(node.rhs)
            except TypeError as e:
              # TODO: We need better location info, as we blame the var name now
              # This also relies on errors from CPython, so the errors aren't
              # great.  For example 'mystr->bad' says "string indices must be
              # integers" because it's really mystr['bad']
              e_die('Type error in expression: %s', str(e))

            val = _PyObjectToVal(py_val)  # type: value_t

            self.mem.SetValue(vd_lval, val, scope_e.LocalOnly, 

M spec/oil-expr.test.sh => spec/oil-expr.test.sh +23 -1
@@ 704,7 704,29 @@ yes
no
## END

#### 3 ~== '3'
#### Exact equality with == and !=
shopt -s oil:all

if (3 == 3) {
  echo 'ok'
}
if (3 == '3') {
  echo 'FAIL'
}

if (3 != 3) {
  echo 'FAIL'
}
if (3 != '3') {
  echo 'ok'
}

## STDOUT:
ok
ok
## END

#### Approximate equality with ~==
shopt -s oil:all

# TODO: should we have !~== too?

M spec/oil-user-feedback.test.sh => spec/oil-user-feedback.test.sh +15 -0
@@ 192,3 192,18 @@ json write :e
  }
]
## END

#### Invalid op on string
shopt -s oil:all

var clients = {'email': 'foo'}
for c in @clients {
  echo $c
  # A user tickled this.  I think this should make the whole 'const' line fail
  # with code 1 or 2?
  const e = c->email
}
## status: 1
## STDOUT:
email
## END