Skip to content
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

Pretty printer using wrong unparsing module for rules #1611

Closed
wants to merge 16 commits into from

Conversation

radumereuta
Copy link
Contributor

Fixes: #1509

@ehildenb
Copy link
Member

@radumereuta can you check if any of these changes are corrections that need to be applied regardless of the source issue? If so, can you provide examples? Otherwise, I think we need to close this until the discussion on the attached issue is finished.

@radumereuta
Copy link
Contributor Author

@dwightguth please have another look.
I've changed the test from json to kore, and it fails on master with:

kast --input kore --output kore out.kore --debug
java.util.NoSuchElementException: key not found: #SemanticCastToK
	at scala.collection.MapLike.default(MapLike.scala:232)
	at scala.collection.MapLike.default$(MapLike.scala:231)
	at scala.collection.AbstractMap.default(Map.scala:59)
	at scala.collection.MapLike.apply(MapLike.scala:141)
	at scala.collection.MapLike.apply$(MapLike.scala:140)
	at scala.collection.AbstractMap.apply(Map.scala:59)
	at org.kframework.compile.AddSortInjections.production(AddSortInjections.java:409)
	at org.kframework.compile.AddSortInjections.visitChildren(AddSortInjections.java:178)
	at org.kframework.compile.AddSortInjections.internalAddSortInjections(AddSortInjections.java:152)
	at org.kframework.compile.AddSortInjections.visitChildren(AddSortInjections.java:189)
	at org.kframework.compile.AddSortInjections.internalAddSortInjections(AddSortInjections.java:125)
	at org.kframework.compile.AddSortInjections.visitChildren(AddSortInjections.java:189)
	at org.kframework.compile.AddSortInjections.internalAddSortInjections(AddSortInjections.java:125)
	at org.kframework.compile.AddSortInjections.visitChildren(AddSortInjections.java:189)
	at org.kframework.compile.AddSortInjections.internalAddSortInjections(AddSortInjections.java:125)
	at org.kframework.compile.AddSortInjections.addSortInjections(AddSortInjections.java:87)
	at org.kframework.unparser.KPrint.prettyPrint(KPrint.java:182)
	at org.kframework.unparser.KPrint.prettyPrint(KPrint.java:152)
	at org.kframework.unparser.KPrint.prettyPrint(KPrint.java:140)
	at org.kframework.kast.KastFrontEnd.run(KastFrontEnd.java:147)
	at org.kframework.main.FrontEnd.main(FrontEnd.java:62)
	at org.kframework.main.Main.runApplication(Main.java:119)
	at org.kframework.main.Main.runApplication(Main.java:109)
	at org.kframework.main.Main.main(Main.java:57)
[Error] Internal: Uncaught exception thrown of type NoSuchElementException
(NoSuchElementException: key not found: #SemanticCastToK)

@ehildenb
Copy link
Member

ehildenb commented Nov 3, 2020

It looks OK to me, looks like the major change is just that with PROGRAM unparser, you use a different module than with the other ones. Looks like you've also made the example test as a Kore-to-Kore test, which is good for avoiding any problems with the JSON KAST format.

Would still like @dwightguth to have a look though.

@radumereuta
Copy link
Contributor Author

This PR doesn't actually fix the original issue. It fixes the kore to kore transformations (should be considered more of a validation) which was also broken.
The problem with JSON still remains since it's a lossy transformation, and during unparsing it fails to reproduce the proper terms.
So I guess @dwightguth should also have a look.

@dwightguth
Copy link
Collaborator

If we're just talking about kast -i kore -o kore, I don't like this as a solution. It would be better to make AddSortInjections aware of the semantic casts when they are applied to variables and use it to construct the correctly sorted variable. as it currently stands, I don't believe you're going to end up with the right output AST.

@radumereuta
Copy link
Contributor Author

Now that you mention it, the input and output are significantly different sort wise.
So the most likely culprit is AddSortInjections? (just so I know where to look first)

@ehildenb ehildenb closed this Nov 10, 2020
@ehildenb ehildenb deleted the issue1509 branch November 10, 2020 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] [kast] - Cannot parse json configurations with #And at top.
3 participants