From eaaff7cc52c2add94b0905f68bc754afaaa8c565 Mon Sep 17 00:00:00 2001 From: Alex Mykyta Date: Sun, 9 Apr 2023 23:09:22 -0700 Subject: [PATCH] Fix mishandled implicit boolean assignment for donttest/dontcompare properties. #167 --- systemrdl/__about__.py | 2 +- systemrdl/properties/builtin.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/systemrdl/__about__.py b/systemrdl/__about__.py index ecd1ac8..c00420d 100644 --- a/systemrdl/__about__.py +++ b/systemrdl/__about__.py @@ -1 +1 @@ -__version__ = "1.25.5" +__version__ = "1.25.6" diff --git a/systemrdl/properties/builtin.py b/systemrdl/properties/builtin.py index 362a444..17606f5 100644 --- a/systemrdl/properties/builtin.py +++ b/systemrdl/properties/builtin.py @@ -5,6 +5,7 @@ from .. import component as comp from .. import node as m_node from ..ast.cast import AssignmentCast +from ..ast.ast_node import ASTNode from .. import rdltypes if TYPE_CHECKING: @@ -64,8 +65,10 @@ def assign_value(self, comp_def: comp.Component, value: Any, src_ref: 'SourceRef # If assigned to any other components, exclusively cast it to a boolean if not isinstance(comp_def, comp.Field): value = comp_def.properties[self.get_name()] - value = AssignmentCast(self.env, src_ref, value, bool) - comp_def.properties[self.get_name()] = value + if isinstance(value, ASTNode): + # was not an implicit True assignment + value = AssignmentCast(self.env, src_ref, value, bool) + comp_def.properties[self.get_name()] = value def validate(self, node: m_node.Node, value: Any) -> None: donttest = node.get_property('donttest') @@ -145,8 +148,10 @@ def assign_value(self, comp_def: comp.Component, value: Any, src_ref: 'SourceRef # If assigned to any other components, exclusively cast it to a boolean if not isinstance(comp_def, comp.Field): value = comp_def.properties[self.get_name()] - value = AssignmentCast(self.env, src_ref, value, bool) - comp_def.properties[self.get_name()] = value + if isinstance(value, ASTNode): + # was not an implicit True assignment + value = AssignmentCast(self.env, src_ref, value, bool) + comp_def.properties[self.get_name()] = value def validate(self, node: m_node.Node, value: Any) -> None: if isinstance(node, m_node.FieldNode):