From 489fec44370d84186dce0f55a2aa3b14ffa43af4 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 28 Dec 2018 15:50:18 +1100 Subject: [PATCH] Remove parse's Options.AllowBuiltIns --- lang/check/resolve.go | 5 +---- lang/parse/parse.go | 15 +-------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/lang/check/resolve.go b/lang/check/resolve.go index 873fd6a4..cf99f3d6 100644 --- a/lang/check/resolve.go +++ b/lang/check/resolve.go @@ -118,9 +118,6 @@ func (c *Checker) parseBuiltInFuncs(ss []string, generic bool) (map[t.QQID]*a.Fu } buf := []byte(nil) - opts := parse.Options{ - AllowBuiltIns: true, - } for _, s := range ss { buf = buf[:0] buf = append(buf, "pub func "...) @@ -141,7 +138,7 @@ func (c *Checker) parseBuiltInFuncs(ss []string, generic bool) (map[t.QQID]*a.Fu } } } - file, err := parse.Parse(c.tm, filename, tokens, &opts) + file, err := parse.Parse(c.tm, filename, tokens, nil) if err != nil { return nil, fmt.Errorf("check: parsing %q: could not parse built-in funcs: %v", s, err) } diff --git a/lang/parse/parse.go b/lang/parse/parse.go index d666e4a7..27b62a00 100644 --- a/lang/parse/parse.go +++ b/lang/parse/parse.go @@ -24,9 +24,6 @@ import ( ) type Options struct { - // TODO: drop AllowBuiltIns as those names are package-qualified - // ("base.u32" and not a bare "u32")? - AllowBuiltIns bool AllowDoubleUnderscoreNames bool } @@ -131,7 +128,7 @@ func (p *parser) parseTopLevelDecl() (*a.Node, error) { if err != nil { return nil, err } - // TODO: check AllowBuiltIns and AllowDoubleUnderscoreNames? + // TODO: check AllowDoubleUnderscoreNames? typ, err := p.parseTypeExpr() if err != nil { @@ -161,12 +158,6 @@ func (p *parser) parseTopLevelDecl() (*a.Node, error) { } // TODO: should we require id0 != 0? In other words, always methods // (attached to receivers) and never free standing functions? - if !p.opts.AllowBuiltIns { - if id0 != 0 && id0.IsBuiltIn() { - return nil, fmt.Errorf(`parse: built-in %q used for func receiver at %s:%d`, - p.tm.ByID(id0), p.filename, p.line()) - } - } if !p.opts.AllowDoubleUnderscoreNames && isDoubleUnderscore(p.tm.ByID(id1)) { return nil, fmt.Errorf(`parse: double-underscore %q used for func name at %s:%d`, p.tm.ByID(id1), p.filename, p.line()) @@ -235,10 +226,6 @@ func (p *parser) parseTopLevelDecl() (*a.Node, error) { if err != nil { return nil, err } - if !p.opts.AllowBuiltIns && name.IsBuiltIn() { - return nil, fmt.Errorf(`parse: built-in %q used for struct name at %s:%d`, - p.tm.ByID(name), p.filename, p.line()) - } if !p.opts.AllowDoubleUnderscoreNames && isDoubleUnderscore(p.tm.ByID(name)) { return nil, fmt.Errorf(`parse: double-underscore %q used for struct name at %s:%d`, p.tm.ByID(name), p.filename, p.line())