diff --git a/pkg/compiler/analysis.go b/pkg/compiler/analysis.go index b79d1de85..09681d69e 100644 --- a/pkg/compiler/analysis.go +++ b/pkg/compiler/analysis.go @@ -86,34 +86,12 @@ func countGlobals(f ast.Node) (i int64) { return } -// isIdentBool looks if the given ident is a boolean. -func isIdentBool(ident *ast.Ident) bool { - return ident.Name == "true" || ident.Name == "false" -} - // isExprNil looks if the given expression is a `nil`. func isExprNil(e ast.Expr) bool { v, ok := e.(*ast.Ident) return ok && v.Name == "nil" } -// makeBoolFromIdent creates a bool type from an *ast.Ident. -func makeBoolFromIdent(ident *ast.Ident, tinfo *types.Info) (types.TypeAndValue, error) { - var b bool - switch ident.Name { - case "true": - b = true - case "false": - b = false - default: - return types.TypeAndValue{}, fmt.Errorf("givent identifier cannot be converted to a boolean => %s", ident.Name) - } - return types.TypeAndValue{ - Type: tinfo.ObjectOf(ident).Type(), - Value: constant.MakeBool(b), - }, nil -} - // resolveEntryPoint returns the function declaration of the entrypoint and the corresponding file. func resolveEntryPoint(entry string, pkg *loader.PackageInfo) (*ast.FuncDecl, *ast.File) { var ( diff --git a/pkg/compiler/codegen.go b/pkg/compiler/codegen.go index 54ca11b4d..5720f948b 100644 --- a/pkg/compiler/codegen.go +++ b/pkg/compiler/codegen.go @@ -610,14 +610,7 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor { return nil case *ast.Ident: - if isIdentBool(n) { - value, err := makeBoolFromIdent(n, c.typeInfo) - if err != nil { - c.prog.Err = err - return nil - } - c.emitLoadConst(value) - } else if tv := c.typeAndValueOf(n); tv.Value != nil { + if tv := c.typeAndValueOf(n); tv.Value != nil { c.emitLoadConst(tv) } else { c.emitLoadVar(n.Name)