Surface parser error in plcParserOption option parsing#7780
Open
zeme-wana wants to merge 3 commits into
Open
Conversation
plcParserOption option parsing
Unisay
reviewed
May 13, 2026
Contributor
Unisay
left a comment
There was a problem hiding this comment.
Well done!
One question on the tests, though. This PR changes the user-visible error text (what people see in GHC logs when an option value is malformed), but the diff doesn't add a single golden file. So there's no recorded "before vs after": if someone later swaps show e for something less informative, CI won't notice.
Patterns for golden tests over error text already exist in the repo:
testParseErrorGoldenatplutus-core/untyped-plutus-core/testlib/Generators/Spec.hs:249-257: captureserrorBundlePrettyoutput directly, essentially the same casenestedGoldenVsErrorOrThingatplutus-core/plutus-core/test/TypeSynthesis/Spec.hs:65-68: PLC type errorsgoldenTypeFromPiratplutus-core/testlib/PlutusIR/Test.hs:249-261: PIR typecheck errorsplutus-tx-plugin/test/Plugin/Errors/Spec.hs:39-56: closest in spirit, since these are plugin errors too
A minimal new test could:
- feed
processOptions(or whichever top-level entry point applies) an option with broken PLC, e.g.context-eqwith an unbalanced paren; - run it through
renderParseError; - compare against a
.goldenfile with the expected message including source position.
That would also cover readOption and fromReadOption, where the new "could not parse value" and "expected Int" strings currently have no test coverage either.
Not a blocker. Just a bit odd that the whole change is about error text, and there's no error text in the tests.
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.
What
The PLC parser error in
plcParserOption(inPlutusTx.Options) was captured as_eand discarded — addressing the-- TODO: use the errorleft at that call site.The
CannotParseValueconstructor's third field was aSomeTypeRep, but every one of the three construction sites (plcParserOption,readOption,fromReadOption) passedsomeTypeRep (Proxy @Int)as a placeholder, regardless of the actual type being parsed. So the rendered message was always:…which is misleading for
plcParserOption(the parser isn't necessarily forInt) and offers no detail on why parsing failed.Change
SomeTypeRepfield ofCannotParseValuewith aTextdetail.plcParserOptionnow threadsText.pack (show e)through —PlutusCore.Error.ParserErrorBundle'sShowinstance renders via Megaparsec'serrorBundlePretty, which produces a human-readable error with source position.readOptionandfromReadOptionpass short honest descriptions ("could not parse value","expected Int") instead of the bogusIntproxy.renderParseErrorformats the detail inline after:.Data.Proxyimport.CannotParseValueis only pattern-matched byrenderParseErrorin this same module (verified by codebase-wide search), so the field shape change is safe.Verification
cabal build plutus-tx-plugin— clean, no new warnings.cabal test plutus-tx-plugin:plutus-tx-plugin-tests— all 841 tests pass.Checklist
plutus-tx-plugin/changelog.d/20260512_use_parser_error.md)