From: Brendan Hansen Date: Thu, 4 Mar 2021 22:54:22 +0000 (-0600) Subject: small bugfix with negative integer literals X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=2b4f8402f1ea388fc400c3c0f757282bf68adf91;p=onyx.git small bugfix with negative integer literals --- diff --git a/bin/onyx b/bin/onyx index aff2fa02..09501951 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/docs/bugs b/docs/bugs index 18955716..ebd71fb7 100644 --- a/docs/bugs +++ b/docs/bugs @@ -15,6 +15,14 @@ List of known bugs: println("Test 2"); } +[ ] Array literals used as default values for struct members can break things. + + Foo :: struct { + arr : [5] u32 = u32.[ 2, 3, 5, 7, 11 ]; + } + + foo := Foo.{}; OR foo := new(Foo); + [ ] Aliasing in many cases does not work. For example: SomeNamespace :: struct { diff --git a/src/onyxastnodes.c b/src/onyxastnodes.c index c1ae983c..f1204715 100644 --- a/src/onyxastnodes.c +++ b/src/onyxastnodes.c @@ -511,7 +511,7 @@ Type* resolve_expression_type(AstTyped* node) { if (node->kind == Ast_Kind_NumLit && node->type->kind == Type_Kind_Basic) { if (node->type->Basic.kind == Basic_Kind_Int_Unsized) { - if ((((u64) ((AstNumLit *) node)->value.l) >> 32) > 0) + if (bh_abs(((AstNumLit *) node)->value.l) >= (1ull << 32)) convert_numlit_to_type((AstNumLit *) node, &basic_types[Basic_Kind_I64]); else convert_numlit_to_type((AstNumLit *) node, &basic_types[Basic_Kind_I32]);