From: Brendan Hansen Date: Thu, 27 Apr 2023 16:00:25 +0000 (-0500) Subject: fixed: miscellaneous segfaults X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=41a2c4efca78248c747139cd7c9e49e91328decc;p=onyx.git fixed: miscellaneous segfaults --- diff --git a/compiler/src/clone.c b/compiler/src/clone.c index 0bcdd608..c44ec994 100644 --- a/compiler/src/clone.c +++ b/compiler/src/clone.c @@ -133,6 +133,7 @@ AstNode* ast_clone_with_captured_entities(bh_allocator a, void* n, bh_arr(AstNod AstNode* cloned = ast_clone(a, n); *ents = captured_entities; + captured_entities = NULL; return cloned; } diff --git a/compiler/src/symres.c b/compiler/src/symres.c index 6478c882..c0dd191e 100644 --- a/compiler/src/symres.c +++ b/compiler/src/symres.c @@ -339,18 +339,22 @@ static SymresStatus symres_field_access(AstFieldAccess** fa) { token_toggle_end((*fa)->token); AstPackage *package = (AstPackage *) strip_aliases((AstNode *) (*fa)->expr); + char *package_name = "unknown (compiler bug)"; + if (package && package->package) { + package_name = package->package->name; + } if (closest) { onyx_report_error((*fa)->token->pos, Error_Critical, "'%b' was not found in package '%s'. Did you mean '%s'?", (*fa)->token->text, (*fa)->token->length, - package->package->name, + package_name, closest); } else { onyx_report_error((*fa)->token->pos, Error_Critical, "'%b' was not found in package '%s'. Perhaps it is defined in a file that wasn't loaded?", (*fa)->token->text, (*fa)->token->length, - package->package->name); + package_name); } return Symres_Error;