mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Remove check.Error.OtherFoo fields
This commit is contained in:
1 parent
6f43ab4b92
commit
3b1d3d0a39
1 file changed
+26
-45
+26
-45
@@ -30,24 +30,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Error struct {
|
type Error struct {
|
||||||
Err error
|
Err error
|
||||||
Filename string
|
Filename string
|
||||||
Line uint32
|
Line uint32
|
||||||
OtherFilename string
|
|
||||||
OtherLine uint32
|
|
||||||
|
|
||||||
TMap *t.Map
|
TMap *t.Map
|
||||||
Facts []*a.Expr
|
Facts []*a.Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Error) Error() string {
|
func (e *Error) Error() string {
|
||||||
s := ""
|
s := fmt.Sprintf("%s at %s:%d", e.Err, e.Filename, e.Line)
|
||||||
if e.OtherFilename != "" || e.OtherLine != 0 {
|
|
||||||
s = fmt.Sprintf("%s at %s:%d and %s:%d",
|
|
||||||
e.Err, e.Filename, e.Line, e.OtherFilename, e.OtherLine)
|
|
||||||
} else {
|
|
||||||
s = fmt.Sprintf("%s at %s:%d", e.Err, e.Filename, e.Line)
|
|
||||||
}
|
|
||||||
if e.TMap == nil {
|
if e.TMap == nil {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@@ -307,15 +299,6 @@ func (c *Checker) checkUse(node *a.Node) error {
|
|||||||
func (c *Checker) checkStatus(node *a.Node) error {
|
func (c *Checker) checkStatus(node *a.Node) error {
|
||||||
n := node.AsStatus()
|
n := node.AsStatus()
|
||||||
qid := n.QID()
|
qid := n.QID()
|
||||||
if other, ok := c.statuses[qid]; ok {
|
|
||||||
return &Error{
|
|
||||||
Err: fmt.Errorf("check: duplicate status %s", qid.Str(c.tm)),
|
|
||||||
Filename: n.Filename(),
|
|
||||||
Line: n.Line(),
|
|
||||||
OtherFilename: other.Filename(),
|
|
||||||
OtherLine: other.Line(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if qid[0] == 0 {
|
if qid[0] == 0 {
|
||||||
if c.topLevelNames[qid[1]] != 0 {
|
if c.topLevelNames[qid[1]] != 0 {
|
||||||
return &Error{
|
return &Error{
|
||||||
@@ -325,6 +308,12 @@ func (c *Checker) checkStatus(node *a.Node) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.topLevelNames[qid[1]] = a.KStatus
|
c.topLevelNames[qid[1]] = a.KStatus
|
||||||
|
} else if c.statuses[qid] != nil {
|
||||||
|
return &Error{
|
||||||
|
Err: fmt.Errorf("check: duplicate top level name %q", qid.Str(c.tm)),
|
||||||
|
Filename: n.Filename(),
|
||||||
|
Line: n.Line(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.statuses[qid] = n
|
c.statuses[qid] = n
|
||||||
|
|
||||||
@@ -335,15 +324,6 @@ func (c *Checker) checkStatus(node *a.Node) error {
|
|||||||
func (c *Checker) checkConst(node *a.Node) error {
|
func (c *Checker) checkConst(node *a.Node) error {
|
||||||
n := node.AsConst()
|
n := node.AsConst()
|
||||||
qid := n.QID()
|
qid := n.QID()
|
||||||
if other, ok := c.consts[qid]; ok {
|
|
||||||
return &Error{
|
|
||||||
Err: fmt.Errorf("check: duplicate const %s", qid.Str(c.tm)),
|
|
||||||
Filename: n.Filename(),
|
|
||||||
Line: n.Line(),
|
|
||||||
OtherFilename: other.Filename(),
|
|
||||||
OtherLine: other.Line(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if qid[0] == 0 {
|
if qid[0] == 0 {
|
||||||
if c.topLevelNames[qid[1]] != 0 {
|
if c.topLevelNames[qid[1]] != 0 {
|
||||||
return &Error{
|
return &Error{
|
||||||
@@ -353,6 +333,12 @@ func (c *Checker) checkConst(node *a.Node) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.topLevelNames[qid[1]] = a.KConst
|
c.topLevelNames[qid[1]] = a.KConst
|
||||||
|
} else if c.consts[qid] != nil {
|
||||||
|
return &Error{
|
||||||
|
Err: fmt.Errorf("check: duplicate top level %q", qid.Str(c.tm)),
|
||||||
|
Filename: n.Filename(),
|
||||||
|
Line: n.Line(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.consts[qid] = n
|
c.consts[qid] = n
|
||||||
|
|
||||||
@@ -417,15 +403,6 @@ func (c *Checker) checkConstElement(n *a.Expr, nb bounds, nLists int) error {
|
|||||||
func (c *Checker) checkStructDecl(node *a.Node) error {
|
func (c *Checker) checkStructDecl(node *a.Node) error {
|
||||||
n := node.AsStruct()
|
n := node.AsStruct()
|
||||||
qid := n.QID()
|
qid := n.QID()
|
||||||
if other, ok := c.structs[qid]; ok {
|
|
||||||
return &Error{
|
|
||||||
Err: fmt.Errorf("check: duplicate struct %s", qid.Str(c.tm)),
|
|
||||||
Filename: n.Filename(),
|
|
||||||
Line: n.Line(),
|
|
||||||
OtherFilename: other.Filename(),
|
|
||||||
OtherLine: other.Line(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if qid[0] == 0 {
|
if qid[0] == 0 {
|
||||||
if c.topLevelNames[qid[1]] != 0 {
|
if c.topLevelNames[qid[1]] != 0 {
|
||||||
return &Error{
|
return &Error{
|
||||||
@@ -435,6 +412,12 @@ func (c *Checker) checkStructDecl(node *a.Node) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.topLevelNames[qid[1]] = a.KStruct
|
c.topLevelNames[qid[1]] = a.KStruct
|
||||||
|
} else if c.structs[qid] != nil {
|
||||||
|
return &Error{
|
||||||
|
Err: fmt.Errorf("check: duplicate top level name %q", qid.Str(c.tm)),
|
||||||
|
Filename: n.Filename(),
|
||||||
|
Line: n.Line(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.structs[qid] = n
|
c.structs[qid] = n
|
||||||
c.unsortedStructs = append(c.unsortedStructs, n)
|
c.unsortedStructs = append(c.unsortedStructs, n)
|
||||||
@@ -583,13 +566,11 @@ func (c *Checker) checkFuncSignature(node *a.Node) error {
|
|||||||
// implicit "return out"?
|
// implicit "return out"?
|
||||||
|
|
||||||
qqid := n.QQID()
|
qqid := n.QQID()
|
||||||
if other, ok := c.funcs[qqid]; ok {
|
if c.funcs[qqid] != nil {
|
||||||
return &Error{
|
return &Error{
|
||||||
Err: fmt.Errorf("check: duplicate function %s", qqid.Str(c.tm)),
|
Err: fmt.Errorf("check: duplicate top level name %q", qqid.Str(c.tm)),
|
||||||
Filename: n.Filename(),
|
Filename: n.Filename(),
|
||||||
Line: n.Line(),
|
Line: n.Line(),
|
||||||
OtherFilename: other.Filename(),
|
|
||||||
OtherLine: other.Line(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.funcs[qqid] = n
|
c.funcs[qqid] = n
|
||||||
|
|||||||
Reference in new issue
Block a user