-
Notifications
You must be signed in to change notification settings - Fork 1.7k
NNBD const evaluation error in String.fromEnvironment #40501
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
Comments
That looks like a bug in the implementation of |
This also affects language_2/string/const_interpolation2_test |
Front-end relies on sdk/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart Lines 1755 to 1787 in 3a8264c
It is using default value only if sdk/pkg/vm/bin/kernel_service.dart Lines 241 to 258 in 3a8264c
So this map is calling We can probably change /cc @askeksa-google |
Alternatively, we can change the way environment defines are provided to the front end into an We have talked about making this change in any case, as it is cleaner than having the kernel service masquerade behind the |
There is no added functionality which would allow you to distinguish an unset environment from one set to the default value from user code. I think the Is it possible for the VM to go behind the abstraction in its implementation of the |
Is this a blocker for unforking? ( @leafpetersen @franklinyow ) |
I think this is a blocker - if I understand correctly, it's a regression in the existing behavior of the constructor. |
There are two problems described in this issue:
If we decide to go ahead with the breaking change we need to fix problem 2 (probably when that breaking change is back-ported to the default core libraries). |
Further work on this issue is awaiting the SDK implementation of #40678 |
lib_2/isolate/string_from_environment_default_value_test.dart is failing in the NNBD SDK. Both expectations fail:
The failures are because the API was changed to default
defaultValue
to an empty string rather than null:So the first expect is easily fixed by updating it to expect an empty string rather than null. The second failure is more interesting, and that's what this bug is about.
The issue is that
const String.fromEnvironment('NOT_FOUND', defaultValue: 'x')
is returning an empty string even thoughdefaultValue
is given. Some other interesting data points:const
modifier, the test passes. I think this means its a const eval bug, and the VM implementation works.= ""
from the method signature, reverting it back to a null default, then the call returns"x"
and the test passes.= ""
to something else, like"hi"
, then this string is returned from the call in the test. So that part of the plumbing is working.My guess is that there's something in the const evaluator that is checking whether the defaultValue is provided by comparing it to null, so the default value of empty string looks like a provided value.
The text was updated successfully, but these errors were encountered: