Commit 8cf717f2 authored by Hugo Moreau's avatar Hugo Moreau
Browse files

new pass created for non static use of goroutines

* transform/checktype.go: Here.
parent 0e466683
Pipeline #14701 passed with stage
in 1 minute and 7 seconds
......@@ -10,6 +10,7 @@ import (
The TypeChecker triggers errors for uses of :
- Array
- Channel
- GoRoutines Declarations outside main function
- Interface
- Map
- Non-integer variable
......@@ -22,6 +23,7 @@ The TypeChecker triggers errors for uses of :
*/
type TypeChecker struct {
currentFunction *ast.Object
}
// Pre traversal check if there is use of variable other than integers.
......@@ -47,6 +49,17 @@ func (t *TypeChecker) Pre(meta *Meta, v *Visitor) bool {
}
case *ast.ChanType:
panic("Channels are not supported.")
case *ast.FuncDecl:
t.currentFunction = node.Name.Obj
case *ast.GoStmt:
switch c.Parent().(type) {
case *ast.BlockStmt:
if t.currentFunction.Name != "main" {
panic("GoRoutines are not supported outside of main declaration.")
}
default:
panic("GoRoutines are not supported outside of main declaration.")
}
case *ast.Ident:
if node.Name == "panic" {
panic("Panics 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