diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-13 02:02:30 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-13 02:02:30 -0400 |
| commit | d094049f8134307382301fcfb55dc006b955f585 (patch) | |
| tree | bc6de38c0bc04880bf76987de3e292dc8a81ebc2 /typecheck.c | |
| parent | 94a3714686391321ed0842a808c7895d092cc000 (diff) | |
Fix bug in logic for detecting constant strings
Diffstat (limited to 'typecheck.c')
| -rw-r--r-- | typecheck.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/typecheck.c b/typecheck.c index 4952fbd7..743165ce 100644 --- a/typecheck.c +++ b/typecheck.c @@ -1359,7 +1359,7 @@ type_t *parse_type_string(env_t *env, const char *str) PUREFUNC bool is_constant(env_t *env, ast_t *ast) { switch (ast->tag) { - case Bool: case Num: case Null: case TextLiteral: return true; + case Bool: case Num: case Null: return true; case Int: { auto info = Match(ast, Int); if (info->bits == IBITS_UNSPECIFIED) { @@ -1373,8 +1373,10 @@ PUREFUNC bool is_constant(env_t *env, ast_t *ast) auto text = Match(ast, TextJoin); 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; + return is_constant(env, text->children->ast); + } + case TextLiteral: { + CORD literal = Match(ast, TextLiteral)->cord; CORD_pos i; #pragma GCC diagnostic ignored "-Wsign-conversion" CORD_FOR(i, literal) { |
