From 337aa911a9027602d47cd56ddbfcde0230a48943 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 2 Sep 2024 19:53:09 -0400 Subject: Auto promote to C String from Text --- compile.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'compile.c') 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)) { -- cgit v1.2.3