-
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
Unhandled exception: Crash when compiling: Null check operator used on a null value #54267
Comments
Managed to found what was the issue, there was an import for which its content was not copied over in the docker image. I will close this as it's fixed. |
Glad you were able to get everything working @cosminbodnariuc! However, it'd be great if the CFE(compiler frontend) didn't crash in this scenario, but rather provided information to help you debug the situation. Could you provide more details on the issue and what your fix was? |
@parlough The problem was that some files (.dart files) within the
The issue was caused when the
but the files were not present in the folder. |
I stumbled across this issue when I was playing with enhanced enums and using switch-case on them. Here are a couple of somewhat MRE for this issue (although completely made up and nonsense code):
enum A {
a(0),
b(1),
final int value;
const A(this.value);
}
int fn(A a) => switch (a) {
A.a => 0,
A.b => 1,
};
enum A {
a(0),
b(1);
final int value2;
const A(this.value);
}
int fn(A a) => switch (a) {
A.a => 0,
A.b => 1,
}; With these examples I get the exact same stack trace as in the original post. My SDK version:
Hope it helps for those who need a sensible compiler error, but got the compiler crashing instead. Or it may help compiler developers to fix the issue. |
I am currently hitting what looks like the same error, with different line numbers, while compiling an Analyzer plugin: 1704305394332:PluginErr:RequestErrorCode.PLUGIN_ERROR:IsolateSpawnException:: Unable to spawn isolate:: Crash when compiling::
Null check operator used on a null value
#0 CfeEnumOperations.getEnumElementValue (package::front_end/src/fasta/kernel/exhaustiveness.dart::395::70)
#1 EnumInfo._createEnumElements (package::_fe_analyzer_shared/src/exhaustiveness/types/enum.dart::60::49)
#2 EnumInfo.enumElements (package::_fe_analyzer_shared/src/exhaustiveness/types/enum.dart::47::45)
#3 EnumStaticType._createEnumElements (package::_fe_analyzer_shared/src/exhaustiveness/types/enum.dart::97::22)
#4 EnumStaticType.enumElements (package::_fe_analyzer_shared/src/exhaustiveness/types/enum.dart::92::58)
#5 EnumStaticType.getSubtypes (package::_fe_analyzer_shared/src/exhaustiveness/types/enum.dart::90::64)
#6 _Checker._unmatched (package::_fe_analyzer_shared/src/exhaustiveness/exhaustive.dart::131::31)
#7 reportErrors (package::_fe_analyzer_shared/src/exhaustiveness/exhaustive.dart::43::30)
#8 ConstantsTransformer._checkExhaustiveness (package::front_end/src/fasta/kernel/constant_evaluator.dart::1569::9)
#9 ConstantsTransformer.visitPatternSwitchStatement (package::front_end/src/fasta/kernel/constant_evaluator.dart::1534::5)
#10 PatternSwitchStatement.accept1 (package::kernel/src/ast/patterns.dart::1862::14)
#11 RemovingTransformer.transform (package::kernel/visitor.dart::1883::17)
#12 LabeledStatement.transformOrRemoveChildren (package::kernel/ast.dart::9422::14)
#13 RemovingTransformer.defaultTreeNode (package::kernel/visitor.dart::2166::10)
#14 TreeVisitor1Default.defaultStatement (package::kernel/visitor.dart::743::48)
#15 StatementVisitor1DefaultMixin.visitLabeledStatement (package::kernel/visitor.dart::2559::7)
#16 LabeledStatement.accept1 (package::kernel/ast.dart::9407::9)
#17 RemovingTransformer.transformOrRemove (package::kernel/visitor.dart::1919::21)
#18 ConstantsTransformer.visitBlock (package::front_end/src/fasta/kernel/constant_evaluator.dart::827::27)
#19 Block.accept1 (package::kernel/ast.dart::9198::58)
#20 RemovingTransformer.transform (package::kernel/visitor.dart::1883::17)
#21 ConstantsTransformer.visitFunctionNode (package::front_end/src/fasta/kernel/constant_evaluator.dart::650::19)
#22 FunctionNode.accept1 (package::kernel/ast.dart::3890::9)
#23 RemovingTransformer.transform (package::kernel/visitor.dart::1883::17)
#24 ConstantsTransformer.visitProcedure.<anonymous closure> (package::front_end/src/fasta/kernel/constant_evaluator.dart::561::23)
#25 ConstantEvaluator.withNewEnvironment (package::front_end/src/fasta/kernel/constant_evaluator.dart::5484::18)
#26 ConstantsTransformer.visitProcedure (package::front_end/src/fasta/kernel/constant_evaluator.dart::559::23)
#27 Procedure.accept1 (package::kernel/ast.dart::3246::55)
#28 RemovingTransformer.transformOrRemove (package::kernel/visitor.dart::1919::21)
#29 RemovingTransformer.transformList (package::kernel/visitor.dart::2143::19)
#30 RemovingTransformer.transformProcedureList (package::kernel/visitor.dart::2035::5)
#31 ConstantsTransformer.visitClass.<anonymous closure> (package::front_end/src/fasta/kernel/constant_evaluator.dart::514::7)
#32 ConstantEvaluator.withNewEnvironment (package::front_end/src/fasta/kernel/constant_evaluator.dart::5484::18)
#33 ConstantsTransformer.visitClass (package::front_end/src/fasta/kernel/constant_evaluator.dart::509::23)
#34 Class.accept1 (package::kernel/ast.dart::1464::53)
#35 RemovingTransformer.transformOrRemove (package::kernel/visitor.dart::1919::21) I am going to trry to debug this on my end a bit. Because that stack trace is probably not helpful without a repro :D |
Oh, I missed that this comment has a perfect minimal repro. @johnniwinther any chance we can prioritize this, as it seems to be blocking some of my work? What's weird is that I don't think there is any erroneous code in my case, I think all of my enum definitions are sound. So I can also keep looking at why my code is triggering this, and maybe produce a minimal repro with valid Dart code. |
Thanks much! |
I'm receiving the following error when trying to compile the dart code within a Dockerfile:
The output for
dart --version
from theDockerfile
is:Dart SDK version: 3.2.0 (stable) (Tue Nov 14 18:26:59 2023 +0000) on "linux_x64"
The output for
dart info
thrown an error when running it within Dockerfile, here are the logs for it:Here is my
Dockerfile
:For more context, here is my project structure:
core
folder is a package module that contains shared data models used both by the Flutter app and the back-end dart codebackend/cloud_run/
where the pubspec.yaml file is also located, in the pubspec, we reference the core module this way:The text was updated successfully, but these errors were encountered: