diff options
| author | 2026-10-14 17:00:26 +0330 | |
|---|---|---|
| committer | 2026-10-14 17:00:26 +0330 | |
| commit | 6ef2efb750622819a3ba3ae9ee061e512c1266d6 (patch) | |
| tree | 2c99f8f8691780bf6c57cccf405115f7b84ba0d1 /src/compiler | |
| parent | prototypes: parameters may be unnamed, int f(int, int*); (appendix b.2.13) (diff) | |
len: len on a char* is an error with typecheck off too (appendix b.2.14)
Diffstat (limited to 'src/compiler')
| -rw-r--r-- | src/compiler/builtins.zc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/builtins.zc b/src/compiler/builtins.zc index 6dc586a..cbc380e 100644 --- a/src/compiler/builtins.zc +++ b/src/compiler/builtins.zc @@ -706,7 +706,8 @@ int array_len(word t) { return 0; } if (t[0] == TY_ARR) { op(O_DROP); lit(t[3]); } - else { tcneed(t[0] == TY_DYN || t == tword, "len needs an array", t); if (argloc >= 0) { op(O_DROP); vaddr(o3cache[argloc] + 1); op(O_LD); } else if (o3on && t[0] == TY_DYN) op(O_LD); else callname(s_dlen); } + else { if (!tc_on && t[0] == TY_PTR && t[4][0] == TY_CHAR) serr("len needs an array, not a char* (use rt.len_w, or a bstr)"); // b.2.14: it would read word 0 + tcneed(t[0] == TY_DYN || t == tword, "len needs an array", t); if (argloc >= 0) { op(O_DROP); vaddr(o3cache[argloc] + 1); op(O_LD); } else if (o3on && t[0] == TY_DYN) op(O_LD); else callname(s_dlen); } xty = tint; xlenloc = -1; xstamp = 0; if (a >= 0 && t[0] == TY_DYN && t[3]) xlenloc = a; // the whole expression is len of a fixed array |
