aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-07 18:43:54 +0200
committerlemon <lsof@mailbox.org>2022-08-07 18:43:54 +0200
commitb3fd91158524dac377ddb756f44f8e3fe67d9cea (patch)
tree3925b57918c53932729d160a148aeaab9dba433b /bootstrap
parent9460f9f14dd68eb59d36f758272be936300a0440 (diff)
allow def inside aggregate
Diffstat (limited to 'bootstrap')
-rw-r--r--bootstrap/parse.c2
-rw-r--r--bootstrap/test2.cff9
2 files changed, 6 insertions, 5 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c
index 99560d8..5019c50 100644
--- a/bootstrap/parse.c
+++ b/bootstrap/parse.c
@@ -2423,7 +2423,7 @@ aggdeclyield(struct decl *decl, void *arg) {
if (decl->t == Dtype && decl->ty == a->aggty)
;
- else if (decl->t == Dfn && !decl->externp)
+ else if ((decl->t == Dfn && !decl->externp) || decl->t == Ddef)
vec_push(a->decls, decl);
else
fatal(a->P, decl->span, "this kind of declaration is disallowed inside aggregates");
diff --git a/bootstrap/test2.cff b/bootstrap/test2.cff
index 356312c..3061d6e 100644
--- a/bootstrap/test2.cff
+++ b/bootstrap/test2.cff
@@ -11,8 +11,9 @@ struct Node<T> {
def X = 7 + 2;
struct Bit<T> {
- fn neg(x T) T { return ~x + X; }
- !fn neg(x T) T { return ~x + Y; }
+ def Z = 3;
+ fn foo(x T) T { return (~x ^ Z) + X; }
+ !fn foo(x T) T { return ~x + Y; }
}
def Y = 3.3;
@@ -31,6 +32,6 @@ extern fn main() void {
n->ok();
x->ok();
- Bit<i32>:neg(3);
- Bit<i64>:neg(3);
+ Bit<i32>:foo(3);
+ Bit<i64>:foo(3);
}