mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 08:52:18 +01:00
Restrict an io_bind io arg to local variables only
This commit is contained in:
1 parent
78c7087eee
commit
b81999f9fc
2 files changed
+15
-6
No files matched your search
@@ -234,8 +234,6 @@ func (g *gen) writeStatementIOBind(b *buffer, n *a.IOBind, depth uint32) error {
|
|||||||
b.writes("{\n")
|
b.writes("{\n")
|
||||||
{
|
{
|
||||||
e := n.IO()
|
e := n.IO()
|
||||||
// TODO: restrict (in the type checker or parser) that e is either a
|
|
||||||
// local variable or args.foo?
|
|
||||||
prefix := vPrefix
|
prefix := vPrefix
|
||||||
if e.Operator() != 0 {
|
if e.Operator() != 0 {
|
||||||
prefix = aPrefix
|
prefix = aPrefix
|
||||||
|
|||||||
+15
-4
@@ -992,16 +992,27 @@ func (p *parser) parseIOBindNode() (*a.Node, error) {
|
|||||||
io.Str(p.tm), p.filename, p.line())
|
io.Str(p.tm), p.filename, p.line())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arg1Name := t.ID(0)
|
||||||
|
if keyword == t.IDIOBind {
|
||||||
|
arg1Name = t.IDData
|
||||||
|
if io.Operator() != 0 {
|
||||||
|
return nil, fmt.Errorf(`parse: invalid %s argument %q at %s:%d`,
|
||||||
|
keyword.Str(p.tm), io.Str(p.tm), p.filename, p.line())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
arg1Name = t.IDLimit
|
||||||
|
if (io.Operator() != 0) && (io.IsArgsDotFoo() == 0) {
|
||||||
|
return nil, fmt.Errorf(`parse: invalid %s argument %q at %s:%d`,
|
||||||
|
keyword.Str(p.tm), io.Str(p.tm), p.filename, p.line())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if x := p.peek1(); x != t.IDComma {
|
if x := p.peek1(); x != t.IDComma {
|
||||||
got := p.tm.ByID(x)
|
got := p.tm.ByID(x)
|
||||||
return nil, fmt.Errorf(`parse: expected ",", got %q at %s:%d`, got, p.filename, p.line())
|
return nil, fmt.Errorf(`parse: expected ",", got %q at %s:%d`, got, p.filename, p.line())
|
||||||
}
|
}
|
||||||
p.src = p.src[1:]
|
p.src = p.src[1:]
|
||||||
|
|
||||||
arg1Name := t.IDData
|
|
||||||
if keyword == t.IDIOLimit {
|
|
||||||
arg1Name = t.IDLimit
|
|
||||||
}
|
|
||||||
if x := p.peek1(); x != arg1Name {
|
if x := p.peek1(); x != arg1Name {
|
||||||
got := p.tm.ByID(x)
|
got := p.tm.ByID(x)
|
||||||
return nil, fmt.Errorf(`parse: expected %q, got %q at %s:%d`, arg1Name.Str(p.tm), got, p.filename, p.line())
|
return nil, fmt.Errorf(`parse: expected %q, got %q at %s:%d`, arg1Name.Str(p.tm), got, p.filename, p.line())
|
||||||
|
|||||||
Reference in new issue
Block a user