aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-02 19:53:09 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-02 19:53:09 -0400
commit337aa911a9027602d47cd56ddbfcde0230a48943 (patch)
treedaf93f7d7972a672ee6a815702c05ce05913fb8b /compile.c
parent6d7a359f8f7757b1e23fa7c0feaf535541dcc84a (diff)
Auto promote to C String from Text
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 82963066..35c5f8f9 100644
--- a/compile.c
+++ b/compile.c
@@ -48,6 +48,12 @@ static bool promote(env_t *env, CORD *code, type_t *actual, type_t *needed)
if (actual->tag == IntType || actual->tag == NumType)
return true;
+ // Text to C String
+ if (actual->tag == TextType && !Match(actual, TextType)->lang && needed->tag == CStringType) {
+ *code = CORD_all("Text$as_c_string(", *code, ")");
+ return true;
+ }
+
// Automatic dereferencing:
if (actual->tag == PointerType && !Match(actual, PointerType)->is_optional
&& can_promote(Match(actual, PointerType)->pointed, needed)) {