mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Add token.ID.IsCannotAssignTo
This commit is contained in:
1 parent
b18209c7dd
commit
89c136ebe4
2 files changed
+6
-2
No files matched your search
+3
-2
@@ -660,9 +660,10 @@ func (p *parser) parseAssignNode() (*a.Node, error) {
|
|||||||
if id := l.Ident(); id.IsLiteral(p.tm) {
|
if id := l.Ident(); id.IsLiteral(p.tm) {
|
||||||
return nil, fmt.Errorf(`parse: assignment LHS %q is a literal at %s:%d`,
|
return nil, fmt.Errorf(`parse: assignment LHS %q is a literal at %s:%d`,
|
||||||
l.Str(p.tm), p.filename, p.line())
|
l.Str(p.tm), p.filename, p.line())
|
||||||
} else if id == t.IDThis {
|
} else if id.IsCannotAssignTo() {
|
||||||
if l == lhs {
|
if l == lhs {
|
||||||
return nil, fmt.Errorf(`parse: cannot assign to "this" at %s:%d`, p.filename, p.line())
|
return nil, fmt.Errorf(`parse: cannot assign to %q at %s:%d`,
|
||||||
|
id.Str(p.tm), p.filename, p.line())
|
||||||
}
|
}
|
||||||
if !p.funcEffect.Impure() {
|
if !p.funcEffect.Impure() {
|
||||||
return nil, fmt.Errorf(`parse: cannot assign to %q in a pure function at %s:%d`,
|
return nil, fmt.Errorf(`parse: cannot assign to %q in a pure function at %s:%d`,
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ func (x ID) IsTightLeft() bool { return x < ID(len(isTightLeft)) && isTightLeft
|
|||||||
func (x ID) IsTightRight() bool { return x < ID(len(isTightRight)) && isTightRight[x] }
|
func (x ID) IsTightRight() bool { return x < ID(len(isTightRight)) && isTightRight[x] }
|
||||||
|
|
||||||
func (x ID) IsAssign() bool { return minAssign <= x && x <= maxAssign }
|
func (x ID) IsAssign() bool { return minAssign <= x && x <= maxAssign }
|
||||||
|
func (x ID) IsCannotAssignTo() bool { return minCannotAssignTo <= x && x <= maxCannotAssignTo }
|
||||||
func (x ID) IsClose() bool { return minClose <= x && x <= maxClose }
|
func (x ID) IsClose() bool { return minClose <= x && x <= maxClose }
|
||||||
func (x ID) IsKeyword() bool { return minKeyword <= x && x <= maxKeyword }
|
func (x ID) IsKeyword() bool { return minKeyword <= x && x <= maxKeyword }
|
||||||
func (x ID) IsNumType() bool { return minNumType <= x && x <= maxNumType }
|
func (x ID) IsNumType() bool { return minNumType <= x && x <= maxNumType }
|
||||||
@@ -398,6 +399,8 @@ const (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
minBuiltInIdent = 0x100
|
minBuiltInIdent = 0x100
|
||||||
|
minCannotAssignTo = 0x100
|
||||||
|
maxCannotAssignTo = 0x101
|
||||||
minNumTypeOrIdeal = 0x10F
|
minNumTypeOrIdeal = 0x10F
|
||||||
minNumType = 0x110
|
minNumType = 0x110
|
||||||
maxNumType = 0x117
|
maxNumType = 0x117
|
||||||
|
|||||||
Reference in new issue
Block a user