aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encoding.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-12-21 14:51:54 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-12-21 14:53:37 +0100
commitbfdfc2603c187447d32ecbc8b5a378df53af5734 (patch)
treecff7440626d57bf7453634c4de4f8e89fc8fc4a6 /prog/encoding.go
parentbc5869180f69e2ad6c6b823e129e08a8e523d800 (diff)
prog: don't fail decoding on non-default out args
We get them in cross-compilation test where an out const arg has different values in different archs. No reason to fail deserialization in that case, replace with default arg instead.
Diffstat (limited to 'prog/encoding.go')
-rw-r--r--prog/encoding.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/prog/encoding.go b/prog/encoding.go
index 1da491186..e4f762756 100644
--- a/prog/encoding.go
+++ b/prog/encoding.go
@@ -382,7 +382,14 @@ func (p *parser) parseArgInt(typ Type) (Arg, error) {
return nil, fmt.Errorf("wrong arg value '%v': %v", val, err)
}
switch typ.(type) {
- case *ConstType, *IntType, *FlagsType, *ProcType, *LenType, *CsumType:
+ case *ConstType, *IntType, *FlagsType, *ProcType, *CsumType:
+ arg := Arg(MakeConstArg(typ, v))
+ if typ.Dir() == DirOut && !typ.isDefaultArg(arg) {
+ p.strictFailf("out arg %v has non-default value: %v", typ, v)
+ arg = typ.DefaultArg()
+ }
+ return arg, nil
+ case *LenType:
return MakeConstArg(typ, v), nil
case *ResourceType:
return MakeResultArg(typ, nil, v), nil