aboutsummaryrefslogtreecommitdiff
path: root/typecheck.c
diff options
context:
space:
mode:
Diffstat (limited to 'typecheck.c')
-rw-r--r--typecheck.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/typecheck.c b/typecheck.c
index 27e20b04..b5a4a4c1 100644
--- a/typecheck.c
+++ b/typecheck.c
@@ -1377,8 +1377,16 @@ bool is_constant(env_t *env, ast_t *ast)
}
case TextJoin: {
auto text = Match(ast, TextJoin);
- // TODO: support short literal strings
- return !text->children;
+ if (!text->children) return true; // Empty string, OK
+ if (text->children->next) return false; // Concatenation, not constant
+
+ CORD literal = Match(text->children->ast, TextLiteral)->cord;
+ CORD_pos i;
+ CORD_FOR(i, literal) {
+ if (!isascii(CORD_pos_fetch(i)))
+ return false; // Non-ASCII requires grapheme logic, not constant
+ }
+ return true; // Literal ASCII string, OK
}
case Not: return is_constant(env, Match(ast, Not)->value);
case Negative: return is_constant(env, Match(ast, Negative)->value);