-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dialects: (builtin) fix true/false printing #3555
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3555 +/- ##
==========================================
- Coverage 90.39% 90.39% -0.01%
==========================================
Files 466 466
Lines 58716 58722 +6
Branches 5592 5593 +1
==========================================
+ Hits 53078 53083 +5
Misses 4204 4204
- Partials 1434 1435 +1 ☔ View full report in Codecov by Sentry. |
@@ -513,7 +528,7 @@ def parse_with_type( | |||
return IntegerAttr(parser.parse_integer(allow_boolean=(type == i1)), type) | |||
|
|||
def print_without_type(self, printer: Printer): | |||
return printer.print(self.value.data) | |||
self.type.print_value_without_type(self.value.data, printer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The polymorphism feels unnecessary to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like this could just be
if isinstance(self.type, IntegerAttr) and self.type.bitwidth == 1:
# print bools
...
else:
printer.print_string(str(self.value.data))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered it and then felt like doing Python runtime polymorphism is cleaner, if only because we have types like DenseArrayBase, and DenseIntOrFPAttr that will soon have a type and then lots of data, and it seems a little simpler to have the functionality available on the type directly.
fc16538
to
bc68c4c
Compare
035fc8a
to
061e87c
Compare
We currently don't consistently print true and false for i1 values, this PR fixes that in the cases I could find.
We currently don't consistently print true and false for i1 values, this PR fixes that in the cases I could find.