-
Notifications
You must be signed in to change notification settings - Fork 483
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
PlutusCore pretty-prints ill-typed PIR code #3445
Comments
I agree, we should pretty-print names with uniques by default. The offending instances in this case are the ones at the bottom of @michaelpj @kwxm @bezirg anybody sees any reason not to replace literally all occurrences of |
All of that stuff is available via |
I'd perhaps go as far as renaming |
I see, thanks! Will use that for the time-being then! |
A minor problem is that if you print something out and re-parse it you get names like |
We have an issue for this: https://jira.iohk.io/browse/SCP-817 We should note that the pretty-printer and parser are 100% not intended for production use. You should use one of the binary formats if you care about that. Although we don't currently have a binary serializer for PIR, we probably should. |
Thanks @michaelpj, I'll use a binary format when available. |
I understand you mentioned the PIR parser is not meant for production, which is why I'm hesitant in creating another issue for this. Still, I have two questions:
The issue follows: Parsing the following
It fails with:
Then, if we erase line 4, it fails with:
|
There is none, sorry. As noted, we're missing a binary format instance for PIR, we should add one. |
Oh that's not true, on master we have a |
Amazing, thanks! :) |
Area
Plutus Foundation Related to the GHC plugin, Haskell-to-Plutus compiler, on-chain code
Summary
When pretty printing some PlutusIR code, by default, the printer doesn't show the
Unique
part of the name which can result in a different program that might not even typecheck.Steps to reproduce
We wrote ourselves a trivially simple validator (I'm happy to add the source here but I don't think its relevant in this case) then pretty printed the resulting PIR with:
This did yield the following bit of PlutusIR:
If we erase all the types, it becomes more readable and the error is apparent:
The
(lam ds (lam ds ds))
should return aCounter
, but returns aValue
instead. In fact, if we parse this program againand try to typecheck it will not typecheck. The relevant PIR definitions for
State
andCounter
are:After looking around, I found the definition in
PlutusCore.Name
, and saw a name has aUnique
component.I then tried to load
PlutusCore.Pretty.ConfigName
but the module is hidden, so I couldn't pretty print a well-typed PIRprogram.
Expected behavior
I'd expect that the pretty printer, even with default options, should not change the semantics of the
program and/or that this is documented and there is an accessible way of importing
PlutusCore.Pretty.ConfigName
.The text was updated successfully, but these errors were encountered: