diff options
| author | gingerBill <bill@gingerbill.org> | 2022-01-27 16:08:47 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-01-27 16:08:47 +0000 |
| commit | 24e7356825a473cba0a1e9962470be73d60ad248 (patch) | |
| tree | 6ac96d9f9f67d2b67dbdd2bbe9319c0a266f2d2a /src/checker.cpp | |
| parent | 16786aac78e343fb11a5bd6c971ebb17ccd36f5c (diff) | |
Add `#no_type_assert` and `#type_assert` to disable implicit type assertions with `x.(T)`
Diffstat (limited to 'src/checker.cpp')
| -rw-r--r-- | src/checker.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index e0c756bb8..038709056 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -4875,6 +4875,9 @@ bool check_proc_info(Checker *c, ProcInfo *pi, UntypedExprInfoMap *untyped, Proc bool bounds_check = (pi->tags & ProcTag_bounds_check) != 0; bool no_bounds_check = (pi->tags & ProcTag_no_bounds_check) != 0; + bool type_assert = (pi->tags & ProcTag_type_assert) != 0; + bool no_type_assert = (pi->tags & ProcTag_no_type_assert) != 0; + if (bounds_check) { ctx.state_flags |= StateFlag_bounds_check; ctx.state_flags &= ~StateFlag_no_bounds_check; @@ -4882,6 +4885,15 @@ bool check_proc_info(Checker *c, ProcInfo *pi, UntypedExprInfoMap *untyped, Proc ctx.state_flags |= StateFlag_no_bounds_check; ctx.state_flags &= ~StateFlag_bounds_check; } + + if (type_assert) { + ctx.state_flags |= StateFlag_type_assert; + ctx.state_flags &= ~StateFlag_no_type_assert; + } else if (no_type_assert) { + ctx.state_flags |= StateFlag_no_type_assert; + ctx.state_flags &= ~StateFlag_type_assert; + } + if (pi->body != nullptr && e != nullptr) { GB_ASSERT((e->flags & EntityFlag_ProcBodyChecked) == 0); } |