From eb47032840551d82bf1222e72c5be979456b31ce Mon Sep 17 00:00:00 2001 From: misomosi Date: Wed, 1 Jul 2026 01:48:00 -0400 Subject: [PATCH] Add ways to diff anon procs with same signature --- src/check_expr.cpp | 6 ++++++ src/exact_value.cpp | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 4709691c5..d76784da3 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -12833,6 +12833,12 @@ gb_internal gbString write_expr_to_string(gbString str, Ast *node, bool shorthan } else { str = gb_string_appendc(str, " ---"); } + // NOTE(tf2spi): + // Two proc literals with the same signature output the same expr above + // which poses challenges for name canonicalization. Include the below + // discriminator with the file ID and offset to help with this. + TokenPos pos = ast_token(node).pos; + str = gb_string_append_fmt(str, " /* %d!%d */", pos.file_id, pos.offset); case_end; case_ast_node(cl, CompoundLit, node); diff --git a/src/exact_value.cpp b/src/exact_value.cpp index 184a8f2e4..b051b0035 100644 --- a/src/exact_value.cpp +++ b/src/exact_value.cpp @@ -1067,8 +1067,8 @@ gb_internal bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y) case ExactValue_Procedure: switch (op) { - case Token_CmpEq: return x.value_typeid == y.value_typeid; - case Token_NotEq: return x.value_typeid != y.value_typeid; + case Token_CmpEq: return x.value_procedure == y.value_procedure; + case Token_NotEq: return x.value_procedure != y.value_procedure; } break;