aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-03-23 22:59:10 +0000
committergingerBill <bill@gingerbill.org>2021-03-23 22:59:10 +0000
commit08f7d3edbe0c530e8565107881fa2443a477b779 (patch)
treedb101ef628d8013103149277192eece60ecaabbe /src/parser.cpp
parentc62980eaeaf36a76c801a8f2745a29c953d6b88a (diff)
Allow `$` in polymorphic record parameter fields (but disallow mixing)
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 46eb9145c..4b77255dc 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -490,6 +490,13 @@ bool ast_node_expect(Ast *node, AstKind kind) {
}
return true;
}
+bool ast_node_expect2(Ast *node, AstKind kind0, AstKind kind1) {
+ if (node->kind != kind0 && node->kind != kind1) {
+ syntax_error(node, "Expected %.*s or %.*s, got %.*s", LIT(ast_strings[kind0]), LIT(ast_strings[kind1]), LIT(ast_strings[node->kind]));
+ return false;
+ }
+ return true;
+}
Ast *ast_bad_expr(AstFile *f, Token begin, Token end) {
Ast *result = alloc_ast_node(f, Ast_BadExpr);
@@ -1863,9 +1870,9 @@ void check_polymorphic_params_for_type(AstFile *f, Ast *polymorphic_params, Toke
}
for_array(i, field->Field.names) {
Ast *name = field->Field.names[i];
- if (name->kind == Ast_PolyType) {
- syntax_error(name, "Polymorphic names are not needed for %.*s parameters", LIT(token.string));
- return; // TODO(bill): Err multiple times or just the once?
+ if (name->kind != field->Field.names[0]->kind) {
+ syntax_error(name, "Mixture of polymorphic names using both $ and not for %.*s parameters", LIT(token.string));
+ return;
}
}
}