mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-28 00:01:48 -07:00
Disallow casting between cstring and []u8
This commit is contained in:
+3
-3
@@ -1926,11 +1926,11 @@ bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// []byte/[]u8 <-> string
|
||||
if (is_type_u8_slice(src) && is_type_string(dst)) {
|
||||
// []byte/[]u8 <-> string (not cstring)
|
||||
if (is_type_u8_slice(src) && (is_type_string(dst) && !is_type_cstring(dst))) {
|
||||
return true;
|
||||
}
|
||||
if (is_type_string(src) && is_type_u8_slice(dst)) {
|
||||
if ((is_type_string(src) && !is_type_cstring(src)) && is_type_u8_slice(dst)) {
|
||||
// if (is_type_typed(src)) {
|
||||
return true;
|
||||
// }
|
||||
|
||||
+12
-2
@@ -1686,7 +1686,14 @@ Ast *parse_operand(AstFile *f, bool lhs) {
|
||||
operand = ast_bad_expr(f, token, f->curr_token);
|
||||
}
|
||||
warning(token, "#run is not yet implemented");
|
||||
} else if (name.string == "file") { return ast_basic_directive(f, token, name.string);
|
||||
} /* else if (name.string == "no_deferred") {
|
||||
operand = parse_expr(f, false);
|
||||
if (unparen_expr(operand)->kind != Ast_CallExpr) {
|
||||
syntax_error(operand, "#no_deferred can only be applied to procedure calls");
|
||||
operand = ast_bad_expr(f, token, f->curr_token);
|
||||
}
|
||||
operand->stmt_state_flags |= StmtStateFlag_no_deferred;
|
||||
} */ else if (name.string == "file") { return ast_basic_directive(f, token, name.string);
|
||||
} else if (name.string == "line") { return ast_basic_directive(f, token, name.string);
|
||||
} else if (name.string == "procedure") { return ast_basic_directive(f, token, name.string);
|
||||
} else if (name.string == "caller_location") { return ast_basic_directive(f, token, name.string);
|
||||
@@ -3887,7 +3894,10 @@ Ast *parse_stmt(AstFile *f) {
|
||||
} else if (tag == "assert") {
|
||||
Ast *t = ast_basic_directive(f, hash_token, tag);
|
||||
return ast_expr_stmt(f, parse_call_expr(f, t));
|
||||
}
|
||||
} /* else if (name.string == "no_deferred") {
|
||||
s = parse_stmt(f);
|
||||
s->stmt_state_flags |= StmtStateFlag_no_deferred;
|
||||
} */
|
||||
|
||||
if (tag == "include") {
|
||||
syntax_error(token, "#include is not a valid import declaration kind. Did you mean 'import'?");
|
||||
|
||||
@@ -173,6 +173,8 @@ enum ProcCallingConvention {
|
||||
enum StmtStateFlag {
|
||||
StmtStateFlag_bounds_check = 1<<0,
|
||||
StmtStateFlag_no_bounds_check = 1<<1,
|
||||
|
||||
StmtStateFlag_no_deferred = 1<<5,
|
||||
};
|
||||
|
||||
enum FieldFlag {
|
||||
|
||||
Reference in New Issue
Block a user