diff --git a/go/src/miller/dsl/cst/assignments.go b/go/src/miller/dsl/cst/assignments.go index 9225cd6a9..ac5d4edf0 100644 --- a/go/src/miller/dsl/cst/assignments.go +++ b/go/src/miller/dsl/cst/assignments.go @@ -58,6 +58,7 @@ func NewAssignmentNode( func (this *AssignmentNode) Execute(state *State) { rvalue := this.rvalue.Evaluate(state) if !rvalue.IsAbsent() { + // xxx need to propagate the error coming back in the Execute() API this.lvalue.Assign(&rvalue, state) } } diff --git a/go/src/miller/dsl/cst/lvalues.go b/go/src/miller/dsl/cst/lvalues.go index 76a6f738f..c9c24d69c 100644 --- a/go/src/miller/dsl/cst/lvalues.go +++ b/go/src/miller/dsl/cst/lvalues.go @@ -98,9 +98,10 @@ func (this *IndirectFieldNameLvalueNode) Assign( lhsFieldName := this.lhsFieldNameExpression.Evaluate(state) if !lhsFieldName.IsString() { - // xxx make and use a Mlrval GetTypeName() return errors.New( - "Miller DSL: computed field name [%s] should be a string but is not.", + "Miller DSL: computed field name [%s] should be a string but was " + + lhsFieldName.GetTypeName() + + ".", ) } diff --git a/go/src/miller/lib/mlrval.go b/go/src/miller/lib/mlrval.go index f217fc941..ad2ee51ef 100644 --- a/go/src/miller/lib/mlrval.go +++ b/go/src/miller/lib/mlrval.go @@ -93,3 +93,15 @@ const ( // function pointers which is MT_DIM x MT_DIM. MT_DIM = 9 ) + +var TYPE_NAMES = [MT_DIM]string{ + "error", + "absent", + "void", + "string", + "int", + "float", + "bool", + "array", + "map", +} diff --git a/go/src/miller/lib/mlrval_accessors.go b/go/src/miller/lib/mlrval_accessors.go index 1290c4d5f..31d2a82be 100644 --- a/go/src/miller/lib/mlrval_accessors.go +++ b/go/src/miller/lib/mlrval_accessors.go @@ -4,6 +4,10 @@ func (this *Mlrval) GetType() MVType { return this.mvtype } +func (this *Mlrval) GetTypeName() string { + return TYPE_NAMES[this.mvtype] +} + func (this *Mlrval) IsError() bool { return this.mvtype == MT_ERROR } diff --git a/go/todo.txt b/go/todo.txt index 6d3ea9d56..16793f4fd 100644 --- a/go/todo.txt +++ b/go/todo.txt @@ -2,9 +2,7 @@ TOP OF LIST: * monday: - o lib.GetTypeName o rename MlrvalOrFunction in the DSL - ! tags file ? ENV * array/map @@ -60,8 +58,13 @@ TOP OF LIST: o begin/end blocks o oosvars o indirect field names, at LHS and RHS + o full indexable at LHS/RHS -- e.g. $*["a"] = $b o support the filter verb +! the DSL needs a full, written-down-and-published spell-out of reference/copy semantics +* then careful CST impl +! likewise error-eval semantics + ---------------------------------------------------------------- MAYBE: