Skip to content
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

Merged
merged 1 commit into from Aug 6, 2019

Conversation

grainier
Copy link
Contributor

@grainier grainier commented Aug 6, 2019

Purpose

Fixes NullPointer exception in the type checker and Fixes #17414

Check List

  • Read the Contributing Guide
  • Required Balo version update
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

Fix NullPointer exception in type checker
@grainier grainier added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Aug 6, 2019
@codecov-io
Copy link

Codecov Report

Merging #17435 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update feb6733...4314a3f. Read the comment docs.

@@ -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))) {
Copy link
Contributor

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?

Copy link
Contributor

@rasika rasika Aug 6, 2019

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.

Copy link
Contributor Author

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.

@gimantha gimantha merged commit 71745bc into ballerina-platform:master Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad Sad Error for Compilation
5 participants