-
Notifications
You must be signed in to change notification settings - Fork 801
Solving Error Number #43815 #44408
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
Solving Error Number #43815 #44408
Changes from all commits
412b16f
db60fc2
0702bb9
66535f6
c95bcd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| @echo off | ||
| echo Using local Ballerina build... | ||
| set BAL_HOME=C:\Users\HP\Desktop\ballerina\my-ballerina-fork\distribution\zip\jballerina\build\distributions\jballerina-2201.13.0-m3 | ||
| set PATH=%BAL_HOME%\bin;%PATH% | ||
|
|
||
| echo Ballerina Version: | ||
| ballerina --version | ||
|
|
||
| echo. | ||
| echo Available commands: | ||
| echo ballerina build | ||
| echo ballerina run | ||
| echo ballerina test | ||
| echo ballerina clean | ||
|
|
||
| echo. | ||
| cmd /k |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| @echo off | ||
| echo Checking local Ballerina... | ||
| "C:\Program Files\Ballerina\jballerina-2201.13.0-m3\bin\bal.bat" --version | ||
|
|
||
| echo. | ||
| echo Checking which ballerina is in PATH... | ||
| where ballerina | ||
|
|
||
| echo. | ||
| echo Current Ballerina version in PATH: | ||
| ballerina --version |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,8 +116,8 @@ | |
| * @since 2.0.0 | ||
| */ | ||
| public class ReachabilityAnalyzer extends SimpleBLangNodeAnalyzer<ReachabilityAnalyzer.AnalyzerData> { | ||
| private static final CompilerContext.Key<ReachabilityAnalyzer> REACHABILITY_ANALYZER_KEY = | ||
| new CompilerContext.Key<>(); | ||
| private static final CompilerContext.Key<ReachabilityAnalyzer> REACHABILITY_ANALYZER_KEY | ||
| = new CompilerContext.Key<>(); | ||
|
Comment on lines
-119
to
+120
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok sir sorry now i will change all these changes because i tried to solve the test cases, to build the whole project. the jdk version i downgrade it because after 3.30 am on the pull request day server founded 404 not found if the link was attached to the google directly it said 404 then again within time so many requests so to make my project work my last option was to downgrade then pull the pr request sir. now i will delete this pr then again folk the repo do the changes then i will re apply the changes |
||
|
|
||
| private final SymbolResolver symResolver; | ||
| private final SymbolTable symTable; | ||
|
|
@@ -343,10 +343,11 @@ public void visit(BLangIf ifStmt, AnalyzerData data) { | |
| } | ||
|
|
||
| private boolean checkAllBranchesTerminate(boolean ifStmtReturnsPanicsOrFails, boolean ifStmtBreakAsLastStatement, | ||
| boolean ifStmtContinueAsLastStatement, AnalyzerData data) { | ||
| boolean ifStmtContinueAsLastStatement, AnalyzerData data) { | ||
| return (ifStmtReturnsPanicsOrFails || ifStmtBreakAsLastStatement | ||
| || ifStmtContinueAsLastStatement) && (data.statementReturnsPanicsOrFails | ||
| || data.breakAsLastStatement || data.continueAsLastStatement); | ||
| || ifStmtContinueAsLastStatement) | ||
| && (data.statementReturnsPanicsOrFails | ||
| || data.breakAsLastStatement || data.continueAsLastStatement); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -566,26 +567,71 @@ public void visit(BLangGroupingKey node, AnalyzerData data) { | |
| } | ||
|
|
||
| @Override | ||
| <<<<<<< HEAD | ||
| public void visit(BLangFunction funcNode, AnalyzerData data) { | ||
| resetFunction(data); | ||
| if (funcNode.flagSet.contains(Flag.NATIVE)) { | ||
| return; | ||
| } | ||
| if (funcNode.body != null) { | ||
| analyzeReachability(funcNode.body, data); | ||
| boolean isNeverReturn = types.isNeverTypeOrStructureTypeWithARequiredNeverMember | ||
| (funcNode.symbol.type.getReturnType()); | ||
| // If the return signature is nil-able, an implicit return will be added in Desugar. | ||
| // Hence, this only checks for non-nil-able return signatures and uncertain return in the body. | ||
| if (!funcNode.symbol.type.getReturnType().isNullable() && !isNeverReturn && | ||
| !data.hasFunctionTerminated) { | ||
| Location closeBracePos = getEndCharPos(funcNode.pos); | ||
|
|
||
| String invokableName; | ||
|
|
||
| if (funcNode.getKind() == NodeKind.RESOURCE_FUNC) { | ||
| invokableName = "resource function"; | ||
| } else { | ||
| invokableName = funcNode.getKind().toString().toLowerCase(); | ||
| ======= | ||
|
Comment on lines
+570
to
+592
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems you have not resolved this conflict properly nor merged properly. |
||
| public void visit(BLangFunction funcNode, AnalyzerData data) { | ||
| resetFunction(data); | ||
| if (funcNode.flagSet.contains(Flag.NATIVE)) { | ||
| return; | ||
| } | ||
| if (funcNode.body != null) { | ||
| analyzeReachability(funcNode.body, data); | ||
| boolean isNeverReturn = types.isNeverTypeOrStructureTypeWithARequiredNeverMember | ||
| (funcNode.symbol.type.getReturnType()); | ||
| // If the return signature is nil-able, an implicit return will be added in Desugar. | ||
| // Hence, this only checks for non-nil-able return signatures and uncertain return in the body. | ||
| boolean isNeverReturn = types | ||
| .isNeverTypeOrStructureTypeWithARequiredNeverMember(funcNode.symbol.type.getReturnType()); | ||
| // If the return signature is nil-able, an implicit return will be added in | ||
| // Desugar. | ||
| // Hence, this only checks for non-nil-able return signatures and uncertain | ||
| // return in the body. | ||
| if (!funcNode.symbol.type.getReturnType().isNullable() && !isNeverReturn && | ||
| !data.hasFunctionTerminated) { | ||
| Location closeBracePos = getEndCharPos(funcNode.pos); | ||
| this.dlog.error(closeBracePos, DiagnosticErrorCode.INVOKABLE_MUST_RETURN, | ||
| funcNode.getKind().toString().toLowerCase()); | ||
|
|
||
| String invokableName; | ||
| if (funcNode.getKind() == NodeKind.RESOURCE_FUNC) { | ||
| invokableName = "resource_function"; | ||
| } else { | ||
| invokableName = funcNode.getKind().toString().toLowerCase(); | ||
| } | ||
|
|
||
| this.dlog.error(closeBracePos, | ||
| DiagnosticErrorCode.INVOKABLE_MUST_RETURN, | ||
| invokableName); | ||
|
|
||
| } else if (isNeverReturn && !data.hasFunctionTerminated) { | ||
| this.dlog.error(funcNode.pos, DiagnosticErrorCode.THIS_FUNCTION_SHOULD_PANIC); | ||
| >>>>>>> 0702bb9f5a0f6888bfc38fb1ecdd305f6b17d503 | ||
| } | ||
|
|
||
| this.dlog.error(closeBracePos, // Fixed typo here | ||
| DiagnosticErrorCode.INVOKABLE_MUST_RETURN, | ||
| invokableName); | ||
| } else if (isNeverReturn && !data.hasFunctionTerminated) { | ||
| this.dlog.error(funcNode.pos, DiagnosticErrorCode.THIS_FUNCTION_SHOULD_PANIC); | ||
| } | ||
| } // Added missing closing brace for the if (funcNode.body != null) block | ||
|
|
||
|
|
||
|
|
||
| BType returnType = Types.getImpliedType(funcNode.returnTypeNode.getBType()); | ||
| if (!funcNode.interfaceFunction && returnType.tag == TypeTags.UNION) { | ||
|
|
@@ -697,8 +743,8 @@ public void visit(BLangBlockFunctionBody body, AnalyzerData data) { | |
| for (BLangStatement stmt : body.stmts) { | ||
| data.env = blockEnv; | ||
| analyzeReachability(stmt, data); | ||
| hasFunctionTerminated |= | ||
| data.statementReturnsPanicsOrFails || (data.isBlockUnreachable && stmt.getKind() == NodeKind.BLOCK); | ||
| hasFunctionTerminated |= data.statementReturnsPanicsOrFails | ||
| || (data.isBlockUnreachable && stmt.getKind() == NodeKind.BLOCK); | ||
| } | ||
| data.hasFunctionTerminated = hasFunctionTerminated; | ||
| } | ||
|
|
@@ -755,7 +801,8 @@ public void visit(BLangDoClause doClause, AnalyzerData data) { | |
| @Override | ||
| public void visit(BLangLetExpression letExpression, AnalyzerData data) { | ||
| // This is to support when let expressions are used in return statements | ||
| // Since variable declarations are visited after return node, this stops false positive unreachable code error | ||
| // Since variable declarations are visited after return node, this stops false | ||
| // positive unreachable code error | ||
| boolean returnStateBefore = data.statementReturnsPanicsOrFails; | ||
| data.statementReturnsPanicsOrFails = false; | ||
| for (BLangLetVariable letVariable : letExpression.letVarDeclarations) { | ||
|
|
@@ -838,7 +885,7 @@ private void resetSkipFurtherAnalysisInUnreachableBlock(AnalyzerData data) { | |
| } | ||
|
|
||
| private void validateAssignmentToNarrowedVariables(List<BLangExpression> exprs, Location location, | ||
| AnalyzerData data) { | ||
| AnalyzerData data) { | ||
| for (BLangExpression expr : exprs) { | ||
| if (expr == null) { | ||
| continue; | ||
|
|
@@ -900,7 +947,8 @@ private void validateAssignmentToNarrowedVariable(BLangSimpleVarRef varRef, Loca | |
| if (loopNode.getKind() == NodeKind.WHILE && | ||
| ((BLangWhile) loopNode).expr.narrowedTypeInfo.containsKey( | ||
| typeNarrower.getOriginalVarSymbol((BVarSymbol) varRef.symbol))) { | ||
| // A while loop may narrow an already narrowed variable, so checking specifically if the loop | ||
| // A while loop may narrow an already narrowed variable, so checking | ||
| // specifically if the loop | ||
| // itself narrows the variable too. | ||
| return; | ||
| } | ||
|
|
@@ -915,7 +963,7 @@ private void validateAssignmentToNarrowedVariable(BLangSimpleVarRef varRef, Loca | |
| } | ||
|
|
||
| private void handleInvalidAssignmentToTypeNarrowedVariableInLoop(List<Location> locations, | ||
| DiagnosticErrorCode errorCode) { | ||
| DiagnosticErrorCode errorCode) { | ||
| for (Location location : locations) { | ||
| dlog.error(location, errorCode); | ||
| } | ||
|
|
@@ -934,8 +982,7 @@ private void handlePotentiallyInvalidAssignmentsToTypeNarrowedVariablesInLoop( | |
| boolean branchTerminates, boolean isLoopBodyOrBranchWithContinueAsLastStmt, DiagnosticErrorCode errorCode, | ||
| Deque<PotentiallyInvalidAssignmentInfo> potentiallyInvalidAssignmentInLoopsInfo) { | ||
|
|
||
| PotentiallyInvalidAssignmentInfo | ||
| currentBranchInfo = potentiallyInvalidAssignmentInLoopsInfo.pop(); | ||
| PotentiallyInvalidAssignmentInfo currentBranchInfo = potentiallyInvalidAssignmentInLoopsInfo.pop(); | ||
|
|
||
| if (branchTerminates) { | ||
| return; | ||
|
|
@@ -1000,8 +1047,8 @@ private static class PotentiallyInvalidAssignmentInfo { | |
| List<Location> locations; | ||
| BLangInvokableNode enclInvokable; | ||
|
|
||
| private PotentiallyInvalidAssignmentInfo(List<Location> locations, | ||
| BLangInvokableNode enclInvokable) { | ||
| private PotentiallyInvalidAssignmentInfo(List<Location> locations, | ||
| BLangInvokableNode enclInvokable) { | ||
| this.locations = locations; | ||
| this.enclInvokable = enclInvokable; | ||
| } | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "image": "ballerina/ballerina-devcontainer:2201.13.0-m3", | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": ["WSO2.ballerina"] | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Ballerina generates this directory during the compilation of a package. | ||
| # It contains compiler-generated artifacts and the final executable if this is an application package. | ||
| target/ | ||
|
|
||
| # Ballerina maintains the compiler-generated source code here. | ||
| # Remove this if you want to commit generated sources. | ||
| generated/ | ||
|
|
||
| # Contains configuration values used during development time. | ||
| # See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details. | ||
| Config.toml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [package] | ||
| org = "hp" | ||
| name = "project" | ||
| version = "0.1.0" | ||
| distribution = "2201.13.0-m3" | ||
|
|
||
| [build-options] | ||
| observabilityIncluded = true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import ballerina/io; | ||
|
|
||
| service class Person { | ||
| resource function get age() returns int { | ||
| do { | ||
| } on fail error err { | ||
| //handle error | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| service class Person { | ||
| resource function get age() returns int { | ||
| do { | ||
| } on fail error err { | ||
| //handle error | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
|
|
||
|
|
||
| service class Person { | ||
| resource function get age() returns int { | ||
| do { | ||
| } on fail error err { | ||
| //handle error | ||
| } | ||
| } | ||
| } |
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.
Why are we downgrading the JDK version here?
Uh oh!
There was an error while loading. Please reload this page.
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.
Please use the appropriate JDK version to build the source code. See Build Ballerina from source.