From 482951b0e0eb99ec5dd122e7f893a007586f83f4 Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Tue, 17 Oct 2023 11:49:57 +0300 Subject: [PATCH] Parser: save enumerator value to field decl node --- src/Parser.zig | 1 + test/cases/ast/types.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Parser.zig b/src/Parser.zig index 823909a1..dfe4bb9b 100644 --- a/src/Parser.zig +++ b/src/Parser.zig @@ -2702,6 +2702,7 @@ fn enumerator(p: *Parser, e: *Enumerator) Error!?EnumFieldAndNode { .node = res.node, } }, }); + try p.value_map.put(node, e.res.val); return EnumFieldAndNode{ .field = .{ .name = interned_name, .ty = res.ty, diff --git a/test/cases/ast/types.c b/test/cases/ast/types.c index e4c714f4..8b111059 100644 --- a/test/cases/ast/types.c +++ b/test/cases/ast/types.c @@ -64,13 +64,13 @@ fn_def: 'fn (a: d[2]const int, b: d[2]const int) void' implicit_return: 'void' enum_decl_two: 'enum E: unsigned int' - enum_field_decl: 'int' + enum_field_decl: 'int' (value: 2) name: A value: implicit_cast: (int_cast) 'int' explicit_cast: (int_cast) 'char' (value: 2) int_literal: 'int' (value: 2) - enum_field_decl: 'int' + enum_field_decl: 'int' (value: 3) name: B value: implicit_cast: (int_cast) 'int'