File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -680,15 +680,18 @@ class Evaluator(
680680 visitExpr(k) match {
681681 case Val .Str (_, k1) => k1
682682 case Val .Null (_) => null
683- case x =>
684- Error .fail(
685- s " Field name must be string or null, not ${x.prettyName}" ,
686- pos
687- )
683+ case x => fieldNameTypeError(x, pos)
688684 }
689685 }
690686 }
691687
688+ private def fieldNameTypeError (fieldName : Val , pos : Position ): Nothing = {
689+ Error .fail(
690+ s " Field name must be string or null, not ${fieldName.prettyName}" ,
691+ pos
692+ )
693+ }
694+
692695 def visitMethod (rhs : Expr , params : Params , outerPos : Position )(implicit
693696 scope : ValScope ): Val .Func =
694697 new Val .Func (outerPos, scope, params) {
@@ -856,11 +859,7 @@ class Evaluator(
856859 Error .fail(s " Duplicate key ${k} in evaluated object comprehension. " , e.pos);
857860 }
858861 case Val .Null (_) => // do nothing
859- case x =>
860- Error .fail(
861- s " Field name must be string or null, not ${x.prettyName}" ,
862- e.pos
863- )
862+ case x => fieldNameTypeError(x, e.pos)
864863 }
865864 }
866865 val valueCache = if (sup == null ) {
You can’t perform that action at this time.
0 commit comments