Reserve the "ideal" name.

Also reject using built-in names as struct or func names.
This commit is contained in:
Nigel Tao committed 2017-05-11 15:45:33 +10:00
1 parent 567e6f7459
commit a8a246be7c
3 files changed
+17 -8

No files matched your search

+3 -8
View File
@@ -12,18 +12,13 @@ import (
t "github.com/google/puffs/lang/token"
)
// DummyTypeIdealNumber is an a.Node.MType field that means that n is an ideal
// numeric constant.
//
// TODO: change 1 to a named constant.
var DummyTypeIdealNumber = a.NewTypeExpr(0, 1, nil, nil, nil)
// DummyTypeIdealNumber is an *ast.Node MType (implicit type) that means that n
// is an ideal numeric constant.
var DummyTypeIdealNumber = a.NewTypeExpr(0, t.IDIdeal, nil, nil, nil)
// TypeString returns a string form of the type n.
func TypeString(m *t.IDMap, n *a.TypeExpr) string {
if n != nil {
if n == DummyTypeIdealNumber {
return "!ideal!"
}
switch n.PackageOrDecorator() {
case 0:
return m.ByID(n.Name())