From c88df4b28baf0bad2e17b7bc850ee9440338adc9 Mon Sep 17 00:00:00 2001 From: Chris O'Brien Date: Thu, 13 Oct 2022 12:01:28 -0500 Subject: [PATCH 1/2] Add enum variant attributes --- sway-core/src/language/ty/declaration/enum.rs | 1 + sway-core/src/semantic_analysis/ast_node/declaration/enum.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/sway-core/src/language/ty/declaration/enum.rs b/sway-core/src/language/ty/declaration/enum.rs index 708f0e02cc3..4d98d29a197 100644 --- a/sway-core/src/language/ty/declaration/enum.rs +++ b/sway-core/src/language/ty/declaration/enum.rs @@ -71,6 +71,7 @@ pub struct TyEnumVariant { pub type_span: Span, pub(crate) tag: usize, pub(crate) span: Span, + pub attributes: AttributesMap, } // NOTE: Hash and PartialEq must uphold the invariant: diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/enum.rs b/sway-core/src/semantic_analysis/ast_node/declaration/enum.rs index e0d484aaef0..ff0f4eff43d 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/enum.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/enum.rs @@ -112,6 +112,7 @@ impl ty::TyEnumVariant { type_span: variant.type_span.clone(), tag: variant.tag, span: variant.span, + attributes: variant.attributes, }, vec![], errors, From f160d51c4a25d7b87aa0dda45bdaeeae9361f43e Mon Sep 17 00:00:00 2001 From: Chris O'Brien Date: Thu, 13 Oct 2022 12:26:49 -0500 Subject: [PATCH 2/2] add attributes to TyEnumVariant test --- sway-core/src/type_system/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sway-core/src/type_system/mod.rs b/sway-core/src/type_system/mod.rs index d61584edaad..3d3f0d70de4 100644 --- a/sway-core/src/type_system/mod.rs +++ b/sway-core/src/type_system/mod.rs @@ -34,7 +34,7 @@ use sway_types::{integer_bits::IntegerBits, Span}; #[test] fn generic_enum_resolution() { - use crate::{language::ty, span::Span, Ident}; + use crate::{language::ty, span::Span, AttributesMap, Ident}; let engine = TypeEngine::default(); let sp = Span::dummy(); @@ -50,6 +50,7 @@ fn generic_enum_resolution() { }), span: sp.clone(), type_span: sp.clone(), + attributes: AttributesMap::default(), }]; let ty_1 = engine.insert_type(TypeInfo::Enum { @@ -65,6 +66,7 @@ fn generic_enum_resolution() { initial_type_id: engine.insert_type(TypeInfo::Boolean), span: sp.clone(), type_span: sp.clone(), + attributes: AttributesMap::default(), }]; let ty_2 = engine.insert_type(TypeInfo::Enum {