Skip to content

Commit

Permalink
Fix function names in error messages
Browse files Browse the repository at this point in the history
Here is another batch.

I found these with a low-tech combination of grep and a script.
There are probably some more cases that I didn't find.
  • Loading branch information
rmolinari committed Aug 12, 2024
1 parent 3aa2822 commit fc779eb
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 126 deletions.
152 changes: 76 additions & 76 deletions evaldo/builtins.go

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions evaldo/builtins_goroutines.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ var Builtins_goroutines = map[string]*env.Builtin{
return *env.NewNative(ps.Idx, ch, "Rye-channel")
default:
ps.FailureFlag = true
return MakeArgError(ps, 1, []env.Type{env.IntegerType}, "new-channel")
return MakeArgError(ps, 1, []env.Type{env.IntegerType}, "channel")
}
},
},
Expand Down Expand Up @@ -249,11 +249,11 @@ var Builtins_goroutines = map[string]*env.Builtin{
if ok {
if hasDeafult {
ps.FailureFlag = true
return MakeBuiltinError(ps, "select can only have one default case", "select")
return MakeBuiltinError(ps, "select can only have one default case", "select\\fn")
}
if defaultFn.Argsn != 0 {
ps.FailureFlag = true
return MakeBuiltinError(ps, "function with 0 args required", "select")
return MakeBuiltinError(ps, "function with 0 args required", "select\\fn")
}
defaultCase := make(chan struct{})
close(defaultCase) // close it immediately so it's always ready to receive
Expand All @@ -269,24 +269,24 @@ var Builtins_goroutines = map[string]*env.Builtin{
native, ok := ps.Res.(env.Native)
if !ok {
ps.FailureFlag = true
return MakeBuiltinError(ps, "first argument of a case must be a channel", "select")
return MakeBuiltinError(ps, "first argument of a case must be a channel", "select\\fn")
}
ch, ok := native.Value.(chan *env.Object)
if !ok {
ps.FailureFlag = true
return MakeBuiltinError(ps, "first argument of a case must be a channel", "select")
return MakeBuiltinError(ps, "first argument of a case must be a channel", "select\\fn")
}
cases = append(cases, reflect.SelectCase{Dir: reflect.SelectRecv, Chan: reflect.ValueOf(ch)})

EvalExpression2(ps, false)
fn, ok := ps.Res.(env.Function)
if !ok {
ps.FailureFlag = true
return MakeBuiltinError(ps, "second argument of a case must be a function", "select")
return MakeBuiltinError(ps, "second argument of a case must be a function", "select\\fn")
}
if fn.Argsn > 1 {
ps.FailureFlag = true
return MakeBuiltinError(ps, "function with 0 or 1 arg required", "select")
return MakeBuiltinError(ps, "function with 0 or 1 arg required", "select\\fn")
}
funcs = append(funcs, fn)
}
Expand All @@ -299,14 +299,14 @@ var Builtins_goroutines = map[string]*env.Builtin{
err := copier.Copy(&psTemp, &ps)
if err != nil {
ps.FailureFlag = true
return MakeBuiltinError(ps, fmt.Sprintf("failed to copy ps: %s", err), "select")
return MakeBuiltinError(ps, fmt.Sprintf("failed to copy ps: %s", err), "select\\fn")
}
var arg env.Object = nil
if recvOK {
val, ok := value.Interface().(*env.Object)
if !ok {
ps.FailureFlag = true
return MakeBuiltinError(ps, "value from channel is not an object", "select")
return MakeBuiltinError(ps, "value from channel is not an object", "select\\fn")
}
arg = *val
}
Expand All @@ -317,7 +317,7 @@ var Builtins_goroutines = map[string]*env.Builtin{

default:
ps.FailureFlag = true
return MakeArgError(ps, 1, []env.Type{env.BlockType}, "select")
return MakeArgError(ps, 1, []env.Type{env.BlockType}, "select\\fn")
}
return arg0
},
Expand Down
2 changes: 1 addition & 1 deletion evaldo/builtins_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var Builtins_http = map[string]*env.Builtin{
return *env.NewNative(ps.Idx, server, "Go-server")
default:
ps.FailureFlag = true
return MakeArgError(ps, 1, []env.Type{env.StringType}, "new-server")
return MakeArgError(ps, 1, []env.Type{env.StringType}, "http-server")
}

},
Expand Down
26 changes: 13 additions & 13 deletions evaldo/builtins_math.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ var Builtins_math = map[string]*env.Builtin{
Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object {
fa, fb, errPos := assureFloats(arg0, arg1)
if errPos > 0 {
return MakeArgError(ps, errPos, []env.Type{env.IntegerType, env.BlockType}, "mod")
return MakeArgError(ps, errPos, []env.Type{env.IntegerType, env.BlockType}, "pow")
}
return *env.NewDecimal(math.Pow(fa, fb))
},
Expand All @@ -135,7 +135,7 @@ var Builtins_math = map[string]*env.Builtin{
case env.Decimal:
return *env.NewDecimal(math.Log2(val.Value))
default:
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "mod")
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "log2")
}
},
},
Expand Down Expand Up @@ -191,7 +191,7 @@ var Builtins_math = map[string]*env.Builtin{
case env.Decimal:
return *env.NewDecimal(math.Pow(val.Value, 2.0))
default:
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "mod")
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "sq")
}
},
},
Expand All @@ -205,7 +205,7 @@ var Builtins_math = map[string]*env.Builtin{
case env.Decimal:
return *env.NewDecimal(math.Sin(val.Value))
default:
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "mod")
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "sin")
}
},
},
Expand All @@ -219,7 +219,7 @@ var Builtins_math = map[string]*env.Builtin{
case env.Decimal:
return *env.NewDecimal(math.Cos(val.Value))
default:
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "mod")
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "cos")
}
},
},
Expand All @@ -233,7 +233,7 @@ var Builtins_math = map[string]*env.Builtin{
case env.Decimal:
return *env.NewDecimal(math.Sqrt(val.Value))
default:
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "mod")
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "sqrt")
}
},
},
Expand All @@ -247,7 +247,7 @@ var Builtins_math = map[string]*env.Builtin{
case env.Decimal:
return *env.NewDecimal(math.Abs(val.Value))
default:
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "mod")
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.BlockType}, "abs")
}
},
},
Expand Down Expand Up @@ -476,10 +476,10 @@ var Builtins_math = map[string]*env.Builtin{
ratio := math.Pow(10, float64(precision.Value))
return env.NewDecimal(math.Round(val.Value*ratio) / ratio)
default:
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.DecimalType}, "dim")
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.DecimalType}, "round\\to")
}
default:
return MakeArgError(ps, 1, []env.Type{env.DecimalType}, "dim")
return MakeArgError(ps, 1, []env.Type{env.DecimalType}, "round\\to")
}
},
},
Expand All @@ -491,7 +491,7 @@ var Builtins_math = map[string]*env.Builtin{
case env.Decimal:
return env.NewDecimal(math.Round(val.Value))
default:
return MakeArgError(ps, 1, []env.Type{env.DecimalType}, "dim")
return MakeArgError(ps, 1, []env.Type{env.DecimalType}, "round\\to")
}
},
},
Expand Down Expand Up @@ -701,7 +701,7 @@ var Builtins_math = map[string]*env.Builtin{
case env.Decimal:
return *env.NewDecimal(math.Y0(val.Value))
default:
return MakeArgError(ps, 1, []env.Type{env.IntegerType, env.DecimalType}, "Y0")
return MakeArgError(ps, 1, []env.Type{env.IntegerType, env.DecimalType}, "y0")
}
},
},
Expand All @@ -715,7 +715,7 @@ var Builtins_math = map[string]*env.Builtin{
case env.Decimal:
return *env.NewDecimal(math.Y1(val.Value))
default:
return MakeArgError(ps, 1, []env.Type{env.IntegerType, env.DecimalType}, "Y1")
return MakeArgError(ps, 1, []env.Type{env.IntegerType, env.DecimalType}, "y1")
}
},
},
Expand Down Expand Up @@ -802,7 +802,7 @@ var Builtins_math = map[string]*env.Builtin{
Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object {
fa, fb, errPos := assureFloats(arg0, arg1)
if errPos > 0 {
return MakeArgError(ps, errPos, []env.Type{env.IntegerType, env.BlockType}, "equals")
return MakeArgError(ps, errPos, []env.Type{env.IntegerType, env.BlockType}, "is-near")
}
const epsilon = 0.0000000000001 // math.SmallestNonzeroFloat64
if math.Abs(fa-fb) <= (epsilon) {
Expand Down
6 changes: 3 additions & 3 deletions evaldo/builtins_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ var Builtins_mysql = map[string]*env.Builtin{
//fmt.Println("Error1")
ps.FailureFlag = true
errMsg := fmt.Sprintf("Error opening SQL: %v", err.Error())
return MakeBuiltinError(ps, errMsg, "mysql-schema//open")
return MakeBuiltinError(ps, errMsg, "mysql-schema//open\\pwd")
} else {
//fmt.Println("Error2")
return *env.NewNative(ps.Idx, db, "Rye-mysql")
}
default:
ps.FailureFlag = true
return MakeArgError(ps, 2, []env.Type{env.StringType}, "mysql-schema//open")
return MakeArgError(ps, 2, []env.Type{env.StringType}, "mysql-schema//open\\pwd")
}
default:
ps.FailureFlag = true
return MakeArgError(ps, 1, []env.Type{env.UriType}, "mysql-schema//open")
return MakeArgError(ps, 1, []env.Type{env.UriType}, "mysql-schema//open\\pwd")
}
},
},
Expand Down
4 changes: 2 additions & 2 deletions evaldo/builtins_psutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ var Builtins_devops = map[string]*env.Builtin{
return arg1
}
default:
return MakeArgError(ps, 1, []env.Type{env.UriType}, "mkdir")
return MakeArgError(ps, 1, []env.Type{env.UriType}, "mv")
}
default:
return MakeArgError(ps, 1, []env.Type{env.UriType}, "mkdir")
return MakeArgError(ps, 1, []env.Type{env.UriType}, "mv")
}
},
},
Expand Down
4 changes: 2 additions & 2 deletions evaldo/builtins_regexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ var Builtins_regexp = map[string]*env.Builtin{
return *env.NewInteger(0)
}
default:
return MakeArgError(ps, 1, []env.Type{env.NativeType}, "regexp//matches")
return MakeArgError(ps, 1, []env.Type{env.NativeType}, "regexp//is-match")
}
default:
return MakeArgError(ps, 2, []env.Type{env.StringType}, "regexp//matches")
return MakeArgError(ps, 2, []env.Type{env.StringType}, "regexp//is-match")
}
},
},
Expand Down
18 changes: 9 additions & 9 deletions evaldo/builtins_spreadsheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,13 @@ var Builtins_spreadsheet = map[string]*env.Builtin{
case env.String:
return WhereContains(ps, spr, col.Value, s.Value, true)
default:
return MakeArgError(ps, 2, []env.Type{env.WordType, env.StringType}, "where-contains")
return MakeArgError(ps, 2, []env.Type{env.WordType, env.StringType}, "where-not-contains")
}
default:
return MakeArgError(ps, 3, []env.Type{env.StringType}, "where-contains")
return MakeArgError(ps, 3, []env.Type{env.StringType}, "where-not-contains")
}
default:
return MakeArgError(ps, 1, []env.Type{env.SpreadsheetType}, "where-contains")
return MakeArgError(ps, 1, []env.Type{env.SpreadsheetType}, "where-not-contains")
}
},
},
Expand Down Expand Up @@ -511,15 +511,15 @@ var Builtins_spreadsheet = map[string]*env.Builtin{
Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object {
dir, ok := arg2.(env.Word)
if !ok {
return MakeArgError(ps, 3, []env.Type{env.WordType}, "sort-col!")
return MakeArgError(ps, 3, []env.Type{env.WordType}, "sort-by!")
}
var dirAsc bool
if dir.Index == ps.Idx.IndexWord("asc") {
dirAsc = true
} else if dir.Index == ps.Idx.IndexWord("desc") {
dirAsc = false
} else {
return MakeBuiltinError(ps, "Direction can be just asc or desc.", "sort-col!")
return MakeBuiltinError(ps, "Direction can be just asc or desc.", "sort-by!")
}
switch spr := arg0.(type) {
case env.Spreadsheet:
Expand All @@ -539,10 +539,10 @@ var Builtins_spreadsheet = map[string]*env.Builtin{
}
return spr
default:
return MakeArgError(ps, 2, []env.Type{env.WordType}, "sort-col!")
return MakeArgError(ps, 2, []env.Type{env.WordType}, "sort-by!")
}
default:
return MakeArgError(ps, 1, []env.Type{env.SpreadsheetType}, "sort-col!")
return MakeArgError(ps, 1, []env.Type{env.SpreadsheetType}, "sort-by!")
}
},
},
Expand Down Expand Up @@ -679,10 +679,10 @@ var Builtins_spreadsheet = map[string]*env.Builtin{
}
return spr
default:
return MakeArgError(ps, 2, []env.Type{env.BlockType}, "add-index!")
return MakeArgError(ps, 2, []env.Type{env.BlockType}, "add-indexes!")
}
default:
return MakeArgError(ps, 1, []env.Type{env.SpreadsheetType}, "add-index!")
return MakeArgError(ps, 1, []env.Type{env.SpreadsheetType}, "add-indexes!")
}
},
},
Expand Down
6 changes: 3 additions & 3 deletions evaldo/builtins_ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ var Builtins_ssh = map[string]*env.Builtin{
return arg0
default:
ps.FailureFlag = true
return MakeArgError(ps, 2, []env.Type{env.FunctionType}, "ssh-server//handle")
return MakeArgError(ps, 2, []env.Type{env.FunctionType}, "ssh-server//password-auth")
}
default:
ps.FailureFlag = true
return MakeArgError(ps, 1, []env.Type{env.NativeType}, "ssh-server//handle")
return MakeArgError(ps, 1, []env.Type{env.NativeType}, "ssh-server//password-auth")
}
},
},
Expand All @@ -94,7 +94,7 @@ var Builtins_ssh = map[string]*env.Builtin{
return arg0
default:
ps.FailureFlag = true
return MakeArgError(ps, 1, []env.Type{env.NativeType}, "Go-server//serve")
return MakeArgError(ps, 1, []env.Type{env.NativeType}, "ssh-server//serve")
}
},
},
Expand Down
10 changes: 5 additions & 5 deletions evaldo/builtins_vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var Builtins_vector = map[string]*env.Builtin{
case env.Vector:
return *env.NewDecimal(govector.Norm(val.Value, 2.0))
default:
return MakeArgError(ps, 1, []env.Type{env.VectorType}, "norm")
return MakeArgError(ps, 1, []env.Type{env.VectorType}, "normalize")
}
},
},
Expand All @@ -62,7 +62,7 @@ var Builtins_vector = map[string]*env.Builtin{
case env.Vector:
return *env.NewDecimal(val.Value.Sd())
default:
return MakeArgError(ps, 1, []env.Type{env.VectorType}, "std-deviation")
return MakeArgError(ps, 1, []env.Type{env.VectorType}, "std-deviation?")
}
},
},
Expand All @@ -77,14 +77,14 @@ var Builtins_vector = map[string]*env.Builtin{
case env.Vector:
res, err := govector.Cosine(v1.Value, v2.Value)
if err != nil {
return MakeBuiltinError(ps, err.Error(), "cosine-similarity")
return MakeBuiltinError(ps, err.Error(), "cosine-similarity?")
}
return *env.NewDecimal(res)
default:
return MakeArgError(ps, 2, []env.Type{env.VectorType}, "cosine-similarity")
return MakeArgError(ps, 2, []env.Type{env.VectorType}, "cosine-similarity?")
}
default:
return MakeArgError(ps, 1, []env.Type{env.VectorType}, "cosine-similarity")
return MakeArgError(ps, 1, []env.Type{env.VectorType}, "cosine-similarity?")
}
},
},
Expand Down
4 changes: 2 additions & 2 deletions evaldo/builtins_web.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ var Builtins_web = map[string]*env.Builtin{
case env.String:
return env.String{"<" + wrp.Value + ">" + str.Value + "</" + wrp.Value + ">"}
default:
return MakeArgError(ps, 1, []env.Type{env.StringType}, "wrap")
return MakeArgError(ps, 1, []env.Type{env.StringType}, "tag")
}
default:
return MakeArgError(ps, 2, []env.Type{env.StringType}, "wrap")
return MakeArgError(ps, 2, []env.Type{env.StringType}, "tag")
}

},
Expand Down

0 comments on commit fc779eb

Please sign in to comment.