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
Fix NullPointer exception in the type checker #17435
Conversation
Fix NullPointer exception in type checker
Codecov Report
@@ Coverage Diff @@
## master #17435 +/- ##
=======================================
Coverage 68.85% 68.85%
=======================================
Files 5 5
Lines 122 122
Branches 21 21
=======================================
Hits 84 84
Misses 38 38 Continue to review full report at Codecov.
|
@@ -3098,7 +3098,7 @@ private BType checkInvocationParam(BLangInvocation iExpr) { | |||
case NAMED_ARGS_EXPR: | |||
BVarSymbol varSymbol = params.get(((BLangNamedArgsExpression) expr).name.value); | |||
if (!env.enclPkg.packageID.equals(iExpr.symbol.pkgID) | |||
&& !Symbols.isFlagOn(varSymbol.flags, Flags.PUBLIC)) { | |||
&& (varSymbol != null && !Symbols.isFlagOn(varSymbol.flags, Flags.PUBLIC))) { |
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.
Shouldn't we see why this var symbol is null in the first place?
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.
Yeah varSymbol is NULL because it is not available in that function signature.
foo(1, 2, nonExixtent=1000);
foo(int a, int b) {...}
This causes compiler to die 🤪, which should not be the case. Rather it should be a diagnostic message.
Use case is you often get these scenarios when you migrate code from 0.991.0 to 1.0.0 due to API changes.
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.
No need, this happens when the user gives a named arg in function invocation, which is not defined in the function signature. So params
won't contain that param, hence resulting in a null.
Purpose
Fixes NullPointer exception in the type checker and Fixes #17414
Check List