diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-06-26 18:20:24 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-06-26 18:20:24 +0100 |
| commit | c949ca2a5c8fe18fd965bd294454243c683a042c (patch) | |
| tree | 4df9a9fc6e697b43327db2a6f9e84c41ab19c7e7 /src/ir.cpp | |
| parent | d974b29f67ea536e1da033e41f3b03e05696f438 (diff) | |
Allow for named arguments for polymorphic procedures
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index d5fc33174..e0ca61522 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4680,15 +4680,19 @@ irValue *ir_build_expr(irProcedure *proc, AstNode *expr) { TypeTuple *pt = &type->params->Tuple; for (isize i = 0; i < param_count; i++) { Entity *e = pt->variables[i]; - GB_ASSERT(e->kind == Entity_Variable); - if (args[i] == NULL) { - if (e->Variable.default_value.kind != ExactValue_Invalid) { - args[i] = ir_value_constant(proc->module->allocator, e->type, e->Variable.default_value); + if (e->kind == Entity_TypeName) { + args[i] = ir_value_nil(proc->module->allocator, e->type); + } else { + GB_ASSERT(e->kind == Entity_Variable); + if (args[i] == NULL) { + if (e->Variable.default_value.kind != ExactValue_Invalid) { + args[i] = ir_value_constant(proc->module->allocator, e->type, e->Variable.default_value); + } else { + args[i] = ir_value_nil(proc->module->allocator, e->type); + } } else { - args[i] = ir_value_nil(proc->module->allocator, e->type); + args[i] = ir_emit_conv(proc, args[i], e->type); } - } else { - args[i] = ir_emit_conv(proc, args[i], e->type); } } |