diff --git a/pkg/eval/compile_effect_test.go b/pkg/eval/compile_effect_test.go index a06d210f..0dfb431d 100644 --- a/pkg/eval/compile_effect_test.go +++ b/pkg/eval/compile_effect_test.go @@ -135,8 +135,8 @@ func TestCommand_Assignment(t *testing.T) { // Assignment errors when the RHS errors. That("x = [][1]").Throws(ErrorWithType(errs.OutOfRange{}), "[][1]"), // Assignment errors itself. - That("true = 1").Throws(vars.ErrSetReadOnlyVar, "true = 1"), - That("@true = 1").Throws(vars.ErrSetReadOnlyVar, "@true = 1"), + That("true = 1").Throws(vars.ErrSetReadOnlyVar, "true"), + That("@true = 1").Throws(vars.ErrSetReadOnlyVar, "@true"), // Arity mismatch. That("x = 1 2").Throws( errs.ArityMismatch{ diff --git a/pkg/eval/compile_lvalue.go b/pkg/eval/compile_lvalue.go index 02edbe1e..b7098551 100644 --- a/pkg/eval/compile_lvalue.go +++ b/pkg/eval/compile_lvalue.go @@ -124,7 +124,7 @@ func (op *assignOp) exec(fm *Frame) Exception { for i, variable := range variables { err := variable.Set(values[i]) if err != nil { - return fm.errorp(op, err) + return fm.errorp(op.lhs.lvalues[i], err) } } } else { @@ -137,18 +137,18 @@ func (op *assignOp) exec(fm *Frame) Exception { for i := 0; i < rest; i++ { err := variables[i].Set(values[i]) if err != nil { - return fm.errorp(op, err) + return fm.errorp(op.lhs.lvalues[i], err) } } restOff := len(values) - len(variables) err := variables[rest].Set(vals.MakeList(values[rest : rest+restOff+1]...)) if err != nil { - return fm.errorp(op, err) + return fm.errorp(op.lhs.lvalues[rest], err) } for i := rest + 1; i < len(variables); i++ { err := variables[i].Set(values[i+restOff]) if err != nil { - return fm.errorp(op, err) + return fm.errorp(op.lhs.lvalues[i], err) } } } diff --git a/pkg/eval/ns_test.go b/pkg/eval/ns_test.go index 7f934ae2..71e4c42a 100644 --- a/pkg/eval/ns_test.go +++ b/pkg/eval/ns_test.go @@ -26,6 +26,6 @@ func TestNs(t *testing.T) { func TestBuiltinFunctionsReadOnly(t *testing.T) { Test(t, - That("return~ = { }").Throws(vars.ErrSetReadOnlyVar, "return~ = { }"), + That("return~ = { }").Throws(vars.ErrSetReadOnlyVar, "return~"), ) } diff --git a/pkg/eval/pwd_test.go b/pkg/eval/pwd_test.go index 7b3f3035..65c39a14 100644 --- a/pkg/eval/pwd_test.go +++ b/pkg/eval/pwd_test.go @@ -24,7 +24,7 @@ func TestBuiltinPwd(t *testing.T) { Test(t, That(`pwd=dir1 put $pwd; put $pwd`).Puts(dir1, tmpHome), - That(`pwd=(float64 1) put $pwd`).Throws(vars.ErrPathMustBeString, "pwd=(float64 1)"), + That(`pwd=(float64 1) put $pwd`).Throws(vars.ErrPathMustBeString, "pwd"), ) // We could separate these two test variants into separate unit test