added: string literals to `cstr`s; miscellaneous bugfixes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 27 Nov 2023 16:44:52 +0000 (10:44 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 27 Nov 2023 16:44:52 +0000 (10:44 -0600)
compiler/src/astnodes.c
core/encoding/json/decoder.onyx
scripts/onyx-pkg.onyx

index d0102cb534edb95ffab269228f0c35dcfe65de6a..0f96e128b98e3c9dfe875f134d017c43cf393160 100644 (file)
@@ -744,6 +744,20 @@ TypeMatch unify_node_and_type_(AstTyped** pnode, Type* type, b32 permanent) {
             return TYPE_MATCH_SUCCESS;
         }
     }
+    
+    // String literals implicitly become c-strings for convience.
+    if (node->kind == Ast_Kind_StrLit
+        && type->kind == Type_Kind_MultiPointer
+        && type->MultiPointer.elem == &basic_types[Basic_Kind_U8]) {
+
+        if (permanent) {
+            AstStrLit *strlit = (AstStrLit *) node;
+            strlit->is_cstr = 1;
+            strlit->type = type;
+        }
+
+        return TYPE_MATCH_SUCCESS;
+    }
 
     // If the destination type is a slice, then automatically convert arrays, dynamic
     // arrays, and var args, if they are the same type. This is big convenience feature
index 9937db7f35c7569aeb71f49dbba4fb7111c59381..fd2f7b27913f89564a29085293bd9c03ca1406fd 100644 (file)
@@ -100,5 +100,5 @@ decode_into :: (data: str, out: &$T) -> Error {
     defer delete(obj);
 
     as_any(obj.root, out);
-    return .None;
+    return .{ .None };
 }
index 398ed6cff56f0645d85e5291a30467821fc664f8..c974b1a01121f6ec96a57d13a73ad01dbad281b9 100644 (file)
@@ -374,6 +374,9 @@ run_rebuild_command :: (args: [] cstr)  {
     }
 
     dep := string.as_str(args[0]);
+    if config.dependencies->has(dep) {
+        dep = config.dependencies->get(dep)->unwrap().source.Git->unwrap();
+    }
 
     info_print("Rebuild", "{}\n", dep);
     if success, err := rebuild_native_library(dep); success {
@@ -392,7 +395,7 @@ run_publish_command :: (args: [] cstr) {
     if !os.dir_exists(".git") {
         error_print("Not in Git repository.\n");
         printf("It does not look like you are in a Git repository. In order to publish packages\n");
-        printf("with onyx-pkg, you have to initailize a Git repository in the current directory.\n\n");
+        printf("with onyx-pkg, you have to initialize a Git repository in the current directory.\n\n");
         return;
     }