Commit 25d4ec27 authored by Hugo Moreau's avatar Hugo Moreau
Browse files

New pass for int arrays used as parameters

* tests/passes/funcIntArrayArgs.go,
  transform/checktype.go: Here.
parent 26bce749
Pipeline #14915 passed with stage
in 1 minute and 23 seconds
package main
func f(s []int) int {
sum := 0
for _, elmt := range s {
sum += elmt
}
return sum
}
func main() {
s := []int{1, 2, 3}
f(s)
}
......@@ -56,6 +56,13 @@ func (t *TypeChecker) Pre(meta *Meta, v *Visitor) bool {
panic("Channels are not supported.")
case *ast.FuncDecl:
t.currentFunction = node.Name.Obj
case *ast.FuncType:
for _, elmt := range node.Params.List {
switch elmt.Type.(type) {
case *ast.ArrayType:
panic("Int array as argument in functions are not supported.")
}
}
case *ast.GoStmt:
switch c.Parent().(type) {
case *ast.BlockStmt:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment