refactor(compiler): improve clarity of common type error messages#1536
Open
sqrew wants to merge 8 commits into
Open
refactor(compiler): improve clarity of common type error messages#1536sqrew wants to merge 8 commits into
sqrew wants to merge 8 commits into
Conversation
- Enhanced UnificationFailed with 'Type mismatch' prefix - Clarified reference return errors with advice on using '@' or owned values - Improved NotAType and NotAmongRegisteredTypes with advice for external types - Refined wording for better developer experience
6e6cf90 to
ceb4787
Compare
hellerve
suggested changes
Apr 17, 2026
Member
hellerve
left a comment
There was a problem hiding this comment.
You’ll also have to update machineReadableErrorStrings.
- Aligned machineReadableErrorStrings with Show instance refinements. - Added suggestions and context to common type error messages. - Verified successful compiler build.
- Updated machineReadableErrorStrings to align with Show instance. - Restored original variable name resolution in UsingDeadReference. - Added memStateNames to MemState to support variable name tracking. - Synced all expected error outputs in test suite. - Verified all core and error tests passing.
hellerve
suggested changes
Apr 26, 2026
Member
hellerve
left a comment
There was a problem hiding this comment.
Some small comments. The memStateNames situation deserves a second look, methinks.
| memStateLifetimes :: Map.Map String LifetimeMode, | ||
| memStateParamDeleters :: Set.Set Deleter | ||
| memStateParamDeleters :: Set.Set Deleter, | ||
| memStateNames :: Map.Map String String |
Member
There was a problem hiding this comment.
I don’t think this does anything unless we key by varOfXObj name. Check
(defn main []
(let [my-var (the (Array Int) [1 2 3])
r (ref my-var)]
(do (delete my-var)
(println* (the &(Array Int) r)))))
You’ll get my_MINUS_var.
| [machineReadableInfoFromXObj fppl xobj ++ " The reference '" ++ pretty xobj ++ "' isn't alive."] | ||
| (UsingDeadReference xobj _ _) -> | ||
| [machineReadableInfoFromXObj fppl xobj ++ " The reference '" ++ pretty xobj ++ "' is no longer valid."] | ||
|
|
| "I encountered a definition that was not at top level: `" ++ pretty xobj ++ "`" | ||
| show (UsingDeadReference xobj dependsOn) = | ||
| "The reference '" ++ pretty xobj ++ "' (depending on the variable '" ++ dependsOn ++ "') isn't alive at " ++ prettyInfoFromXObj xobj ++ "." | ||
| show (UsingDeadReference xobj dependsOn originalName) = |
Member
There was a problem hiding this comment.
We should use either ' or `, not both.
hellerve
reviewed
Apr 30, 2026
Member
hellerve
left a comment
There was a problem hiding this comment.
Just two chunks that I believe are dead code, otherwise this now looks good to go!
hellerve
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refines several common error messages in the Carp compiler to make them more helpful and direct for developers.
Changes:
UnificationFailederrors to make the issue immediately obvious.FunctionsCantReturnRefTyandLetCantReturnRefTyto provide clearer advice on fixing the issue by using@(copy) or returning owned values.NotATypeandNotAmongRegisteredTypesto include a hint about usingregister-typefor external C types.Disclaimer: This PR was built with the assistance of Gemini (an AI assistant) working in collaboration with @sqrew to improve the Carp compiler's user experience.