aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-01-17 19:07:38 +0000
committergingerBill <bill@gingerbill.org>2018-01-17 19:07:38 +0000
commit419ab6f00c5396c1296a78e931693ba38d7ea102 (patch)
treeab4f8cfe76b023c568257260e3adbe28f37d97d9 /src/check_type.cpp
parent5558b55e9f1f7b80c052bc803fd43f317849f98c (diff)
Named return value act as variables; Code reorganization
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index f1a706b6d..e41670bd3 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -1423,10 +1423,16 @@ Type *check_get_results(Checker *c, Scope *scope, AstNode *_results) {
token = name->Ident.token;
}
+ if (is_blank_ident(token)) {
+ error(name, "Result value cannot be a blank identifer `_`");
+ }
+
Entity *param = make_entity_param(c->allocator, scope, token, type, false, false);
+ param->flags |= EntityFlag_Result;
param->Variable.default_value = value;
param->Variable.default_is_nil = default_is_nil;
array_add(&variables, param);
+ add_entity(c, scope, name, param);
}
}
}
@@ -1673,6 +1679,12 @@ bool check_procedure_type(Checker *c, Type *type, AstNode *proc_type_node, Array
}
}
+ if (result_count > 0) {
+ Entity *first = results->Tuple.variables[0];
+ type->Proc.has_named_results = first->token.string != "";
+ }
+
+
ProcCallingConvention cc = pt->calling_convention;
if (cc == ProcCC_ForeignBlockDefault) {
cc = ProcCC_CDecl;