Remove parse's Options.AllowBuiltIns

This commit is contained in:
Nigel Tao committed 2018-12-28 15:50:18 +11:00
1 parent 5cddd4894f
commit 489fec4437
2 files changed
+2 -18

No files matched your search

+1 -4
View File
@@ -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)
}
+1 -14
View File
@@ -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())