small bugfix with negative integer literals
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 4 Mar 2021 22:54:22 +0000 (16:54 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 4 Mar 2021 22:54:40 +0000 (16:54 -0600)
bin/onyx
docs/bugs
src/onyxastnodes.c

index aff2fa02bf42134c2df8f76a4f1fec5a2904f98b..095019512d8c6e779cb6bfc24b50f1b64b262322 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 18955716230cbee12547f0c2489c57efe9fbb409..ebd71fb70e6f9fa8126bb6d622883c34bde4468a 100644 (file)
--- 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 {
index c1ae983cdb8c30da2cbb9a0d1d586c07c6e7c5bd..f12047159abc4f8c176e9bb58568b0688a28a866 100644 (file)
@@ -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]);