Skip to content

Commit

Permalink
Merge pull request #1398 from visualfc/check_slicelit
Browse files Browse the repository at this point in the history
cl: compileCallExpr check one arg for ast.SliceLit
  • Loading branch information
xushiwei authored Jul 24, 2023
2 parents 104daa8 + 77c4a42 commit 4ae9a43
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions cl/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,24 +520,28 @@ func compileCallExpr(ctx *blockCtx, v *ast.CallExpr, inFlags int) {
fn.initWith(fnt, i, -1)
compileCompositeLit(ctx, expr, fn.arg(i, ellipsis), true)
case *ast.SliceLit:
fn.initWith(fnt, i, -2)
t := fn.arg(i, ellipsis)
switch t.(type) {
case *types.Slice:
case *types.Named:
if _, ok := getUnderlying(ctx, t).(*types.Slice); !ok {
if len(v.Args) == 1 {
fn.initWith(fnt, i, -2)
t := fn.arg(i, ellipsis)
switch t.(type) {
case *types.Slice:
case *types.Named:
if _, ok := getUnderlying(ctx, t).(*types.Slice); !ok {
t = nil
}
default:
t = nil
}
default:
t = nil
}
typetype := fn.typetype && t != nil && len(v.Args) == 1
if typetype {
ctx.cb.InternalStack().Pop()
}
compileSliceLit(ctx, expr, t)
if typetype {
return
typetype := fn.typetype && t != nil
if typetype {
ctx.cb.InternalStack().Pop()
}
compileSliceLit(ctx, expr, t)
if typetype {
return
}
} else {
compileSliceLit(ctx, expr, nil)
}
default:
compileExpr(ctx, arg)
Expand Down

0 comments on commit 4ae9a43

Please sign in to comment.