Beispiel #1
0
func (v *UnreachableCheck) PostVisit(s *SemanticAnalyzer, n ast.Node) {
	switch n := n.(type) {
	case *ast.Block:
		for i, c := range n.Nodes {
			if i < len(n.Nodes)-1 && IsNodeTerminating(c) {
				s.Err(n.Nodes[i+1], "Unreachable code")
			}
		}

		if len(n.Nodes) > 0 {
			n.IsTerminating = IsNodeTerminating(n.Nodes[len(n.Nodes)-1])
		}

	case *ast.FunctionDecl:
		v.visitFunction(s, n, n.Function)

	case *ast.LambdaExpr:
		v.visitFunction(s, n, n.Function)
	}

}