修复: byte/rune 长度混淆及错误位置丢失
This commit is contained in:
@@ -61,7 +61,7 @@ func (e *Executor) walk(ctx *Context, ph *Placeholder, sql *strings.Builder, arg
|
||||
val, ok := ctx.Get(n.Name)
|
||||
if !ok {
|
||||
if e.strict {
|
||||
return fmt.Errorf("line %d, col %d: undefined variable %q", n.Pos.Line, n.Pos.Col, n.Name)
|
||||
return PosErrorf(n.Pos.Line, n.Pos.Col, "undefined variable %q", n.Name)
|
||||
}
|
||||
val = nil
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func (e *Executor) walk(ctx *Context, ph *Placeholder, sql *strings.Builder, arg
|
||||
val, ok := ctx.Get(n.Name)
|
||||
if !ok {
|
||||
if e.strict {
|
||||
return fmt.Errorf("line %d, col %d: undefined variable %q", n.Pos.Line, n.Pos.Col, n.Name)
|
||||
return PosErrorf(n.Pos.Line, n.Pos.Col, "undefined variable %q", n.Name)
|
||||
}
|
||||
val = ""
|
||||
}
|
||||
@@ -103,11 +103,11 @@ func (e *Executor) walk(ctx *Context, ph *Placeholder, sql *strings.Builder, arg
|
||||
// skip
|
||||
case *UseNode:
|
||||
if e.blocks == nil {
|
||||
return fmt.Errorf("line %d, col %d: @use(\"%s\") no blocks available", n.Pos.Line, n.Pos.Col, n.Name)
|
||||
return PosErrorf(n.Pos.Line, n.Pos.Col, "@use(\"%s\") no blocks available", n.Name)
|
||||
}
|
||||
blockNodes, ok := e.blocks[n.Name]
|
||||
if !ok {
|
||||
return fmt.Errorf("line %d, col %d: @use(\"%s\") block not found", n.Pos.Line, n.Pos.Col, n.Name)
|
||||
return PosErrorf(n.Pos.Line, n.Pos.Col, "@use(\"%s\") block not found", n.Name)
|
||||
}
|
||||
if err := e.walk(ctx, ph, sql, args, blockNodes); err != nil {
|
||||
return err
|
||||
@@ -159,7 +159,7 @@ func (e *Executor) walkFor(ctx *Context, ph *Placeholder, sql *strings.Builder,
|
||||
case reflect.Slice, reflect.Array:
|
||||
length = rv.Len()
|
||||
default:
|
||||
return fmt.Errorf("line %d, col %d: @for requires a slice or array, got %T", n.Pos.Line, n.Pos.Col, listVal)
|
||||
return PosErrorf(n.Pos.Line, n.Pos.Col, "@for requires a slice or array, got %T", listVal)
|
||||
}
|
||||
|
||||
for i := 0; i < length; i++ {
|
||||
|
||||
Reference in New Issue
Block a user