aboutsummaryrefslogtreecommitdiff
path: root/src/checker/expr.cpp
diff options
context:
space:
mode:
authorGinger Bill <github@gingerbill.org>2016-09-21 14:46:56 +0100
committerGinger Bill <github@gingerbill.org>2016-09-21 14:46:56 +0100
commit0e2347e582147019f904e25cf26aa70259c66e38 (patch)
tree4f3aff27dd23764d3c46afbfd94a4f65a87bc37c /src/checker/expr.cpp
parent31c11a50370ded9865cf8c1da6baabaa97d38a18 (diff)
Filename as default import name; as .; as _; panic()
Diffstat (limited to 'src/checker/expr.cpp')
-rw-r--r--src/checker/expr.cpp18
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;