generate: Fix no return statement, unused variables

This commit is contained in:
Sasha Koshka 2025-08-06 19:07:57 -04:00
parent c18e251b4a
commit a99d4dee66

View File

@ -680,9 +680,6 @@ func (this *Generator) generateDecodeBranch(hash [16]byte, typ Type) (n int, err
n += nn; if err != nil { return n, err }
nn, err = this.generateErrorCheck()
n += nn; if err != nil { return n, err }
indexVar := this.newTemporaryVar("index")
nn, err = this.iprintf("%s := 0\n", indexVar)
n += nn; if err != nil { return n, err }
// validate header
// TODO: here, validate that length is less than the
@ -691,7 +688,7 @@ func (this *Generator) generateDecodeBranch(hash [16]byte, typ Type) (n int, err
// problems
// read fields
nn, err = this.iprintf("for %s = range int(%s) {\n", indexVar, lengthVar)
nn, err = this.iprintf("for _ = range int(%s) {\n", lengthVar)
n += nn; if err != nil { return n, err }
this.push()
// read field header
@ -770,6 +767,8 @@ func (this *Generator) generateDecodeBranch(hash [16]byte, typ Type) (n int, err
default: return n, fmt.Errorf("unexpected type: %T", typ)
}
nn, err = this.iprintf("return n, nil\n")
this.pop()
nn, err = this.iprintf("}\n")
n += nn; if err != nil { return n, err }