From d7f66d5a286a1da1240d5f255b7ae171c8b6a93f Mon Sep 17 00:00:00 2001 From: Mel Date: Thu, 10 Jul 2025 00:59:36 +0200 Subject: Fix nil-dereference in `parser_node_type_class` Signed-off-by: Mel --- boot/parse.c | 3 ++- boot/tests/parse/generics.cskt | 0 boot/tests/parse/simple_types.cskt | 0 boot/tree.c | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 boot/tests/parse/generics.cskt create mode 100644 boot/tests/parse/simple_types.cskt diff --git a/boot/parse.c b/boot/parse.c index 687659e..6363379 100644 --- a/boot/parse.c +++ b/boot/parse.c @@ -445,6 +445,7 @@ parser_function_header_node(struct Parser* p, struct Parser_Error* error) struct Token close_parameters_token = parser_next(p); header.span = span_merge(open_parameters_token.span, close_parameters_token.span); + header.location = open_parameters_token.location; struct Token next = parser_peek(p); struct Token further = parser_peek_further(p); @@ -620,7 +621,7 @@ parser_node_type_class(struct Parser* p, struct Parser_Error* error) // for the sake of consistency and the built-in type node linked list. struct Type_Node* method_type = type_node_new( TYPE_NODE_FUNCTION, (union Type_Node_Value){ .function = { header } }, header.span, - header.parameters_type_and_name->location); + header.location); method_type->value_name = method_name; if (!head) diff --git a/boot/tests/parse/generics.cskt b/boot/tests/parse/generics.cskt new file mode 100644 index 0000000..e69de29 diff --git a/boot/tests/parse/simple_types.cskt b/boot/tests/parse/simple_types.cskt new file mode 100644 index 0000000..e69de29 diff --git a/boot/tree.c b/boot/tree.c index aab05eb..4320279 100644 --- a/boot/tree.c +++ b/boot/tree.c @@ -420,6 +420,7 @@ struct Function_Header_Node struct Type_Node* return_type; struct Span span; + struct Cursor location; }; // a declaration of a variable, constant, or other binding, without a mutability -- cgit 1.4.1