-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Type checking for compile time constants fails in new test ConstInit5NegativeTest #482
Comments
The test ConstInit5NegativeTest is bad, If main is changed to: int main() { The error is: '/sources/alldart/dart/runtime/Test.dart': Error: line 3 pos 11: initializer must be a compile time constant The compiler is not required to report errors at first parse through the source, but can delay it until the moment that the definition is used. Added Invalid label. |
This comment was originally written by [email protected] See spec section 10.1, these are compile time constants and should generate compile time errors. Added New label. |
This comment was originally written by @mhausner C does not get compiled until it's referenced. The spec allows this freedom in the implementation. |
4 Errors and Warnings …A compile-time error must be reported by a Dart compiler before the erroneous code is executed. ConstInit5NegativeTest does not execute the getter of final C. Added Invalid label. |
This comment was originally written by [email protected] OK, thanks for the clarification. I'll update the test and shift this bug to Frog which does try to execute the code. |
I think that the spec allows for an earlier error reporting than VM does. It mandates only the latest point in time that it must be reported. |
This comment was originally written by [email protected] Updated test. final A = 1; int main() { Frog still throws a NSME instead of what looks like a compile-time exception, but its in a place that can't be caught (the assignment of C). I'm going to close out the bug. There are still ongoing discussions about the best ways to test for compile-time errors in the unit test framework. |
This issue was originally filed by [email protected]
The test is passing, but should give a compile time error.
final A = 1;
final B = "Hello";
final C = A + B; // error: sub-expressions of binary + must be numeric
int main() {
}
The text was updated successfully, but these errors were encountered: