From c257c09243c83448725613e79e918ed42b28dddb Mon Sep 17 00:00:00 2001 From: Pablo Fuentes Date: Mon, 5 Feb 2024 19:14:35 -0500 Subject: [PATCH] fix annotations for unions --- tests/parser-cases/annotations.thrift | 4 ++++ thriftpy2/parser/parser.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/parser-cases/annotations.thrift b/tests/parser-cases/annotations.thrift index 81d93d7..8260031 100644 --- a/tests/parser-cases/annotations.thrift +++ b/tests/parser-cases/annotations.thrift @@ -55,3 +55,7 @@ service foo_service { void foo() ( foo = "bar" ) } (a.b="c") +union foo_union { + 1: optional bool abc + 2: optional i32 xyz +} (a.b="c") diff --git a/thriftpy2/parser/parser.py b/thriftpy2/parser/parser.py index 1a06b3b..69783c3 100644 --- a/thriftpy2/parser/parser.py +++ b/thriftpy2/parser/parser.py @@ -229,7 +229,7 @@ def p_seen_struct(p): def p_union(p): - '''union : seen_union '{' field_seq '}' ''' + '''union : seen_union '{' field_seq '}' type_annotations''' val = _fill_in_struct(p[1], p[3]) _add_thrift_meta('unions', val)