Fresh constants for configuration initializers#3557
Merged
rv-jenkins merged 14 commits intodevelopfrom Aug 9, 2023
Merged
Conversation
radumereuta
reviewed
Aug 7, 2023
Contributor
radumereuta
left a comment
There was a problem hiding this comment.
I like the solution a lot.
Added some minor comments/questions.
radumereuta
suggested changes
Aug 8, 2023
Contributor
radumereuta
left a comment
There was a problem hiding this comment.
I modified ResolveAnonVar to carry over the location information from variables
@@ -104,16 +106,16 @@ public class ResolveAnonVar {
@Override
public K apply(KVariable k) {
if (ANON_VAR.equals(k)) {
- return newDotVariable("");
+ return newDotVariable("", k);
}
if (FRESH_ANON_VAR.equals(k)) {
- return newDotVariable("?");
+ return newDotVariable("?", k);
}
if (FRESH_ANON_CONSTANT.equals(k)) {
- return newDotVariable("!");
+ return newDotVariable("!", k);
}
if (FRESH_LIST_VAR.equals(k)) {
- return newDotVariable("@");
+ return newDotVariable("@", k);
}
return super.apply(k);
}
@@ -121,9 +123,10 @@ public class ResolveAnonVar {
}
private int counter = 0;
- KVariable newDotVariable(String prefix) {
+ KVariable newDotVariable(String prefix, K k) {
KVariable newLabel;
- Att att = Att().add(Att.ANONYMOUS());
+ Att att = Att().add(Att.ANONYMOUS()).add(Source.class, k.att().get(Source.class))
+ .add(Location.class, k.att().get(Location.class));
if (prefix.equals("?")) {
att = att.add(Att.FRESH());
}And got the error message to show like this:
[Error] Compiler: Can't resolve fresh configuration variable not of sort Int
while executing phase "Resolve fresh variables in cell initializers" on sentence at
<none>
<none>
Source(/home/radu/work/test/test.k)
Location(16,14,16,16)
16 | <freshFoo> !_:Foo </freshFoo>
. ^~
5 tasks
Closed
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.
fixes #3520