diff options
| author | Paul Chaignon <paul.chaignon@gmail.com> | 2023-11-09 19:20:07 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2023-11-28 10:18:54 +0000 |
| commit | b2566dc325435823ffcfcef3c02016925556f81b (patch) | |
| tree | 2ea69567f76d4dc7848b46ed4ff08480829b389c /pkg/compiler/testdata | |
| parent | 9fe51b7c608bca7b80c06c30f78c7c60810d51f1 (diff) | |
compiler: support type args with mixed kinds
Type args can currently have only one type of kindInt, kindIdent,
kindString, or kindAny. The descriptions are checked against expected
type arg kinds, with kindAny meaning that anything is allowed (often
restricted with custom checks).
Concretely, it means that in a description as follows, arg1 and arg2
can each take a single kind of values.
type[arg1, arg2]
This is limiting if we want arg1 to be able to take both an int or
flags. We thus need type args to support having mixed kinds. This
commit achieves this by turning the kind constants into bit flags.
This will be useful in a subsequent commit, but we can also already use
it for one existing type arg, the first of string types:
string[literal_or_flags, size]
literal_or_flags changes from kindAny to kindIdent|kindString and we can
remove the custom check that used to enforce this.
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'pkg/compiler/testdata')
| -rw-r--r-- | pkg/compiler/testdata/errors.txt | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt index 83b62cfb6..87b9e5f68 100644 --- a/pkg/compiler/testdata/errors.txt +++ b/pkg/compiler/testdata/errors.txt @@ -110,7 +110,7 @@ foo$36(a const[1:2]) ### unexpected ':' foo$39(a fileoff:1) ### type alias fileoff with ':' foo$40(a len["a"]) ### unexpected string "a" for len target argument of len type, expect identifier foo$41(a vma[C1:C2]) -foo$43(a ptr[in, string[1]]) ### unexpected int 1, string arg must be a string literal or string flags +foo$43(a ptr[in, string[1]]) ### unexpected int 1 for literal or flags argument of string type, expect string or identifier 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 @@ -369,7 +369,7 @@ type TT3[A] { foo$213(a ptr[in, TT1[int8]]) -foo$glob001(a ptr[in, glob[1]]) ### unexpected int 1, string arg must be a string literal or string flags +foo$glob001(a ptr[in, glob[1]]) ### unexpected int 1 for literal or flags argument of glob type, expect string or identifier foo$glob002(a ptr[in, glob]) ### glob only accepts 1 arg, provided 0 foo$glob003(a ptr[in, glob["/sys", 5]]) ### glob only accepts 1 arg, provided 2 foo$glob004(a ptr[in, glob["/sys", 5, 2]]) ### wrong number of arguments for type glob, expect [literal or flags], [size], [opt] |
