fix crash when passing empty string to function

This commit is contained in:
Andrew Kelley 2016-04-08 17:08:50 -07:00
parent 4ce85ea067
commit 491e3cb5c5
3 changed files with 11 additions and 1 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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) { }