-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add hints to Const
s to improve the distillation of integer constants
#328
Comments
Const
s to improve distilled outputsConst
s to improve the distillation of integer constants
Adding a custom equality comparison will be handy at any rate - will need to eventually looking at fixing that TODO about float comparisons 😅 |
Oh, I should add that I used to implement a similar thing in v2: fathom/experiments/rust-prototype-v2/src/syntax/mod.rs Lines 35 to 41 in 168a5f9
|
This would not help us dump struct fields with a specific style, would it? |
OHH! You are indeed right! 🤦♂️ This only helps for preserving the style of constants in the original format through elaboration, and back via distillation to pretty printing. Rendering parsed formats in specific styles would be a separate issue. Edit: made a new issue for this here: #329 |
Are consts and other terms associated with a codespan for error reporting purposes? |
Line 55 in 7641402
|
The fact that a const was a particular type of literal in the original source feels related to this range I feel 🤔 |
In the surface language yes, but this info is currently lost once we get into the core language. We'll most likely need to add it to the core language at some stage. This could be handy for stack traces (during evaluation or reading binary formats) that relate to the original fathom code, for instance, or for errors that might occur during compilation/extraction. |
Currently the distiller has know way of knowing how to render constants, instead just defaulting to rendering as decimal numbers. We could fix this by altering
Const
to be:This will allow us to convert back to an appropriate literal (either numeric or string) during distillation.
One thing we'll need to consider is to ignore the style hint when comparing constants for equality. We could do this by a custom overload
PartialEq
, or, by implementing our own method (eg.Const::logical_eq
), which will involve updates tosurface::elaboration::unification
andcore::semantics
:fathom/fathom/src/core/semantics.rs
Line 948 in 7641402
fathom/fathom/src/surface/elaboration/unification.rs
Line 280 in 7641402
Another complication is how to handle the style hints in the primitive/builtin ops - we'll need to ignore or merge them somehow to figure out what to use in the returned constant.
The text was updated successfully, but these errors were encountered: