diff options
| author | Ginger Bill <github@gingerbill.org> | 2016-09-21 14:46:56 +0100 |
|---|---|---|
| committer | Ginger Bill <github@gingerbill.org> | 2016-09-21 14:46:56 +0100 |
| commit | 0e2347e582147019f904e25cf26aa70259c66e38 (patch) | |
| tree | 4f3aff27dd23764d3c46afbfd94a4f65a87bc37c /src/checker/expr.cpp | |
| parent | 31c11a50370ded9865cf8c1da6baabaa97d38a18 (diff) | |
Filename as default import name; as .; as _; panic()
Diffstat (limited to 'src/checker/expr.cpp')
| -rw-r--r-- | src/checker/expr.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/checker/expr.cpp b/src/checker/expr.cpp index 75c0f71f4..9dd761ec6 100644 --- a/src/checker/expr.cpp +++ b/src/checker/expr.cpp @@ -1534,7 +1534,9 @@ b32 check_is_castable_to(Checker *c, Operand *operand, Type *y) { return true; } if (is_type_string(xb) && is_type_u8_slice(yb)) { - return true; + if (is_type_typed(xb)) { + return true; + } } // proc <-> proc @@ -2422,6 +2424,20 @@ b32 check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id) } break; + case BuiltinProc_panic: + // panic :: proc(msg: string) + + if (!is_type_string(operand->type)) { + gbString str = expr_to_string(ce->args[0]); + defer (gb_string_free(str)); + error(ast_node_token(call), + "`%s` is not a string", str); + return false; + } + + operand->mode = Addressing_NoValue; + break; + case BuiltinProc_copy: { // copy :: proc(x, y: []Type) -> int Type *dest_type = NULL, *src_type = NULL; |