-
Notifications
You must be signed in to change notification settings - Fork 262
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
Deprecate unicode-char #5302
Deprecate unicode-char #5302
Conversation
…ny into deprecateUnicodeChar
@@ -1,11 +1,11 @@ | |||
|
|||
// Generating and Running Block-Based Tests: | |||
// RUN: %baredafny generate-tests %args Block %S/TestGenerationNoInliningEnumerativeDefinitions.dfy > %t-tests.dfy | |||
// RUN: %baredafny test %args --unicode-char:false --target:cs "%t-tests.dfy" >> "%t" | |||
// RUN: %baredafny test %args --allow-deprecation --unicode-char false --target:cs "%t-tests.dfy" >> "%t" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dargones how come the test generation blogpost is using --unicode-char false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll remove unicode-char=false here then.
@robin-aws There are quite a few tests using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good change! And this makes Arrays.dfy.go.expect unnecessary now, so we should delete it.
That also says to me that %testDafnyForEachCompiler
should probably fail if a test passes for a backend but one of those expect files exists! That might be worth adding so that we can delete all the unused files, otherwise folks will get confused in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't change anything, besides swapping comp/Arrays
and unicodechars/comp/Arrays
and their related files, and adding --allow-warnings
to the version that has --unicode-char false
, and updating its expect file to include the new warning
@@ -1,7 +1,6 @@ | |||
// NONUNIFORM: Multiple testing scenarios, highly backend sensitive, testing CLI | |||
// RUN: %verify "%s" > "%t" | |||
// RUN: %run --no-verify --target:cs "%s" Csharp 1 >> "%t" | |||
// RUN: %run --no-verify --target:cpp --unicode-char:false "%s" Cpp Yipee >> "%t" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep these, otherwise we're reducing testing coverage for the cpp backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are kept. I've swapped comp/CompileWithArguments.dfy
and unicode/comp/CompileWithArguments.dfy
. I realize this is a confusing change in this PR, and it would have been better to do it before or after, but I think it might be bit of a hassle to extract it as a separate PR now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah got it, that's just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got halfway through reviewing and spotted a problem: the C++ backend ONLY supports --unicode-char false
. So if we unconditionally mark it deprecated we're essentially marking that backend deprecated, which I don't think we should do.
I think we have two options:
- Mark the mode deprecated only for all other backends. I'm not sure how to do that cleanly, since it implies we can't deprecate it when just verifying.
- Implement the mode for C++. That's non-trivial work and likely involves pulling in another runtime dependency, which is why I left it out of scope initially.
Definitely willing to, but reasonable to do in a follow-up PR, since leaving them as is doesn't reduce testing coverage? |
Yes I saw that :-D
I think you're saying that the C++ backend has the same level of support as the other ones, albeit with possibly fewer supported features. If so, then However, I would suggest doing the opposite, and I think you implicitly made the same decision when you made |
Yup I agree this is the best option - we've already been documenting the C++ backend as incomplete/experimental in more ad-hoc ways. If you're saying you want to emit a regular warning when it's used as well, go right ahead! |
Source/TestDafny/MultiBackendTest.cs
Outdated
if (error == "" && OnlyAllowedOutputLines(backend, outputString)) { | ||
if (error == "" && HasUnsupported(backend, outputString)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this do the wrong thing if there are unsupported feature lines but also some unrelated crash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll see if I can change it back. Might have been for something that changed already.
If it doesn't break things badly somehow, can we rename the |
(aside from those in unicodechars and c++) All remaining tests are using —unicode-char as an example for general compatibility testing, or using the C++ backend. The only exception is git-issue-356[-errors].dfy, which could be duplicated for `—unicode-char true` mode, but wouldn’t really add any additional coverage.
I pushed a commit that removes it from just about all of them (see commit message for the caveats) |
Ah switching @keyboardDrummer if you can see how to fix this easily be my guess, otherwise I'll figure it out tomorrow. |
The print statement for Java seems to be one big heuristic: bool isGeneric = type.NormalizeToAncestorType().AsSeqType is { Arg: { IsTypeParameter: true } };
if (type.NormalizeToAncestorType().IsStringType) {
argumentWriter = wr.ForkInParens();
wr.Write(".verbatimString()");
} else if (type.NormalizeToAncestorType().IsCharType && UnicodeCharEnabled) {
wr.Write($"{DafnyHelpersClass}.ToCharLiteral(");
argumentWriter = wr.Fork();
wr.Write(")");
} else if (isGeneric && !UnicodeCharEnabled) {
wr.Write($"((java.util.function.Function<{DafnySeqClass}<?>,String>)(_s -> (_s.elementType().defaultValue().getClass() == java.lang.Character.class ? _s.verbatimString() : String.valueOf(_s)))).apply(");
argumentWriter = wr.Fork();
wr.Write(")");
} else {
wr.Write("java.lang.String.valueOf(");
argumentWriter = wr.Fork();
wr.Write(")");
} I think using reflection as this does is not going to work reliably. Instead you need a virtual method, either the standard I think resolving that will be some work. How about we do not migrate this test yet, and instead file a GH issue to resolve this? |
Actually I think it's likely an easy fix: all those heuristics are exactly what |
Source/TestDafny/MultiBackendTest.cs
Outdated
// If we hit errors, check for known unsupported features or bugs for this compilation target | ||
if (error == "" && OnlyAllowedOutputLines(backend, outputString)) { | ||
return 0; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reverting the other change. Now AFAICT this is identical to lines 357-360, and the if block can't possibly change the result since it returns, so I think you can nuke this too.
Yup turns out there was a helper method for resolving the type of an expression accounting for datatype wrapper erasure, which only Java was calling (probably because it was necessary to handle primitive types correctly). Adding it to the rest of the backends made the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\U1F680
Description
/unicodechar
with their equivalents outside of/unicodechar
, so the tests in the folder are the ones using the non-default--unicode-char false
How has this been tested?
/unicode-char/Arrays.dfy
does not have--allow-deprecation
and outputs the deprecation warning that this PR introducesBy submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.