Repository navigation
Format solver structs without String.Chars dispatch - #60
Merged
Merged
Conversation
Hex vendors the solver into its archive. Mix consolidates the project's protocols during compile with code paths that exclude archives, so the consolidated String.Chars has no impls for the solver structs. Formatting a failed resolution in the same VM after compile interpolated terms, package ranges and constraints and raised Protocol.UndefinedError instead of explaining the failure. Call each struct's to_string/1 directly, and add to_string/1 to the Constraint protocol for constraints, which can be any of four structs. The String.Chars impls stay for library users.
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.
Hex vendors the solver into its archive as
Hex.Solver. When a Mix project compiles, it prunes code paths, including archives, and then consolidates protocols, so the project's consolidatedString.Charshas no impls for the solver's structs. A failed resolution aftercompilein the same VM, such asmix do compile + deps.get, raisedProtocol.UndefinedErrorfromFailureinstead of explaining the conflict, andHEX_DEBUG_SOLVERlogging raised the same way.This calls each struct's
to_string/1directly when formatting, including in theInspectimpls and the debug logs. It addsto_string/1to theConstraintprotocol, since a constraint can be aRange,Union,EmptyorVersion. TheString.Charsimpls stay for library users. The new test tracesString.Chars.to_string/1while a failed solve is formatted and checks that it never receives a solver struct. It fails without the change.I vendored this and #59 into Hex, together with the Hex fix that restores its code paths after compiling. In a project requiring
jason ~> 99.0,mix do compile --no-deps-check + deps.getthen printed the explanation, and withHEX_DEBUG_SOLVER=1it printed the solver log. Without this change both raised. That was on Elixir 1.20.4 / OTP 29.1.1, and the Hex suite passed with the vendored copy.