diff options
| author | gingerBill <bill@gingerbill.org> | 2021-08-09 17:39:38 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-08-09 17:39:38 +0100 |
| commit | aebfa4b28e5d92e493010593f4177f53249aa6b2 (patch) | |
| tree | 4ea63889450b4035ff67ad91aece381286c9924b /src/check_builtin.cpp | |
| parent | a3abe991a4f168baab69e33945038cc10b74d5b5 (diff) | |
Allow `len` and `cap` to return a `uint` if a type hint is `uint` to aid people wanting to use unsigned integers
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 1b68728a0..ea89ec007 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -406,6 +406,16 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 Type *op_type = type_deref(operand->type); Type *type = t_int; + if (type_hint != nullptr) { + Type *bt = type_hint; + // bt = base_type(bt); + if (bt == t_int) { + type = type_hint; + } else if (bt == t_uint) { + type = type_hint; + } + } + AddressingMode mode = Addressing_Invalid; ExactValue value = {}; if (is_type_string(op_type) && id == BuiltinProc_len) { |