diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-09-30 22:52:51 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-09-30 22:52:51 -0400 |
commit | 3f91bb6f0fb9805ff846327a0d6cf3aa9dd1501e (patch) | |
tree | 16b41a32be9926d1666861121f02aee69a960934 | |
parent | 6cebb40221d0fce80fedb4c644ca9278054a4f49 (diff) |
fixed fn() bug
-rw-r--r-- | #test.toc# | 17 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | parse.c | 11 | ||||
-rw-r--r-- | test.toc | 2 |
4 files changed, 23 insertions, 8 deletions
diff --git a/#test.toc# b/#test.toc# new file mode 100644 index 0000000..112e4e3 --- /dev/null +++ b/#test.toc# @@ -0,0 +1,17 @@ +main @= fn() { + arr1 : ['a' as u8]int; + arr2 : [main as u64]int; +1 arr3 : [main as i64]int; + N @= (-10 + (97 as char as f32)) as u32; + arr4 : [N]int; + arr5 : [main as u64]int; + // arr6 : [main as u64 as fn() as u64]int;FIXME + arr7 : [main as u64 as fn() int as u64]int; + + str @= "foo"; + arr8 : [(str[0] as u32) + (str[1] as u32) + (str[2] as u32)]int; + asdf @= new int; + arr9 : [asdf as u64]int; + arr10 : [main as &i32 as u64]int; + arr11 : [((main as &u64) as [4]u64)[3]]int; +}; @@ -1,6 +1,5 @@ /* TODO: -casting errors call fns at compile time finish evaluator fix void fn type @@ -443,8 +443,6 @@ static inline Expression *parser_new_expr(Parser *p) { return parser_malloc(p, sizeof(Expression)); } -/* TODO: check that we check which thing ends it everywhere */ - #define EXPR_CAN_END_WITH_COMMA 0x01 /* a comma could end the expression */ #define EXPR_CAN_END_WITH_LBRACE 0x02 @@ -568,10 +566,11 @@ static bool parse_type(Parser *p, Type *type) { t->token++; /* move past ) */ Type *ret_type = type->fn.types.data; /* if there's a symbol that isn't [ or (, that can't be the start of a type */ - if (t->token->kind == TOKEN_KW - && t->token->kw <= KW_LAST_SYMBOL - && t->token->kw != KW_LSQUARE - && t->token->kw != KW_LPAREN) { + if ((t->token->kind == TOKEN_KW + && t->token->kw <= KW_LAST_SYMBOL + && t->token->kw != KW_LSQUARE + && t->token->kw != KW_LPAREN) + || t->token->kw == KW_AS) { ret_type->kind = TYPE_VOID; ret_type->flags = 0; } else { @@ -5,7 +5,7 @@ main @= fn() { N @= (-10 + (97 as char as u8 as f32)) as u32; arr4 : [N]int; arr5 : [main as u64]int; - // arr6 : [main as u64 as fn() as u64]int;FIXME + arr6 : [main as u64 as fn() as u64]int; arr7 : [main as u64 as fn() int as u64]int; str @= "foo"; |