Commit e0baaeb7 authored by Hugo Moreau's avatar Hugo Moreau
Browse files

Variable name handled

We do not support variable name containing "G2P_tmp_",
because we use them in our transform.
A test have been created to check it.

* transform/checktype.go,
  tests/passes/variablename.go : Here.
parent de486685
Pipeline #13725 passed with stage
in 52 seconds
package main
func f(n int) int {
G2P_tmp_1 := 1
return G2P_tmp_1 * n
}
func main() {
f(1)
}
......@@ -3,6 +3,7 @@ package transform
import (
"go/ast"
"go/token"
"strings"
)
/*
......@@ -37,6 +38,12 @@ func (t *TypeChecker) Pre(meta *Meta, v *Visitor) bool {
case *ast.CompositeLit:
panic("Arrays are not supported.")
}
switch lhn := node.Lhs[i].(type) {
case *ast.Ident:
if strings.Contains(lhn.Name, "G2P_tmp_") {
panic("Variable name must not contain \"G2P_tmp_\"")
}
}
}
case *ast.ChanType:
panic("Channels are not supported.")
......
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