fix crash when passing empty string to function
This commit is contained in:
parent
4ce85ea067
commit
491e3cb5c5
@ -333,6 +333,7 @@ static LLVMValueRef get_handle_value(CodeGen *g, AstNode *source_node, LLVMValue
|
||||
static LLVMValueRef gen_err_name(CodeGen *g, AstNode *node) {
|
||||
zig_panic("TODO");
|
||||
//assert(node->type == NodeTypeFnCallExpr);
|
||||
//assert(g->generate_error_name_table);
|
||||
//AstNode *err_val_node = node->data.fn_call_expr.params.at(0);
|
||||
//LLVMValueRef err_val = gen_expr(g, err_val_node);
|
||||
//arg
|
||||
@ -2895,7 +2896,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, TypeTableEntry *type_entry, ConstE
|
||||
}
|
||||
target_val = LLVMConstArray(child_type->type_ref, values, len);
|
||||
} else {
|
||||
zig_unreachable();
|
||||
return LLVMGetUndef(type_entry->type_ref);
|
||||
}
|
||||
LLVMValueRef global_value = LLVMAddGlobal(g->module, LLVMTypeOf(target_val), "");
|
||||
LLVMSetInitializer(global_value, target_val);
|
||||
|
@ -278,6 +278,9 @@ static void parse_string_literal(ParseContext *pc, Token *token, Buf *buf, bool
|
||||
buf_append_char(buf, '"');
|
||||
if (offset_map) offset_map->append(pos);
|
||||
break;
|
||||
case 'x':
|
||||
zig_panic("TODO");
|
||||
break;
|
||||
default:
|
||||
ast_error(pc, token, "invalid escape character");
|
||||
break;
|
||||
|
@ -554,3 +554,9 @@ fn mem_alloc(T: type)(n: isize) -> %[]T {
|
||||
fn mem_free(T: type)(mem: []T) { }
|
||||
|
||||
|
||||
#attribute("test")
|
||||
fn call_fn_with_empty_string() {
|
||||
accepts_string("");
|
||||
}
|
||||
|
||||
fn accepts_string(foo: []u8) { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user