aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/compiler/check.go2
-rw-r--r--pkg/compiler/testdata/errors.txt1
-rw-r--r--pkg/compiler/types.go2
3 files changed, 3 insertions, 2 deletions
diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go
index 7510429d9..5a3dea450 100644
--- a/pkg/compiler/check.go
+++ b/pkg/compiler/check.go
@@ -404,7 +404,7 @@ func (comp *compiler) checkType(t *ast.Type, isArg, isRet, isResourceBase bool)
comp.error(t.Pos, "unknown type %v", t.Ident)
return
}
- if !desc.AllowColon && t.HasColon {
+ if t.HasColon && (!desc.AllowColon || isArg) {
comp.error(t.Pos2, "unexpected ':'")
return
}
diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt
index 6be60ef91..dc535b000 100644
--- a/pkg/compiler/testdata/errors.txt
+++ b/pkg/compiler/testdata/errors.txt
@@ -108,6 +108,7 @@ foo$43(a ptr[in, string[1]]) ### unexpected int 1, string arg must be a string l
foo$44(a int32) len[a] ### len can't be syscall return
foo$45(a int32) len[b] ### len can't be syscall return
foo$46(a ptr[in, in]) ### unknown type in
+foo$47(a int32:2) ### unexpected ':'
opt { ### struct uses reserved name opt
f1 int32
diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go
index 5db294fda..035a47165 100644
--- a/pkg/compiler/types.go
+++ b/pkg/compiler/types.go
@@ -18,7 +18,7 @@ type typeDesc struct {
CantBeOpt bool // can't be marked as opt?
CantBeRet bool // can't be syscall return (directly or indirectly)?
NeedBase bool // needs base type when used as field?
- AllowColon bool // allow colon (int8:2)?
+ AllowColon bool // allow colon (int8:2) on fields?
ResourceBase bool // can be resource base type?
OptArgs int // number of optional arguments in Args array
Args []namedArg // type arguments