Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions New Text Document.txt
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
11 changes: 11 additions & 0 deletions bal.bat
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
4 changes: 2 additions & 2 deletions build-config/checkstyle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {

tasks.register('downloadFile', Download) {
src([
'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.4/checkstyle/jdk-17/checkstyle.xml',
'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.4/checkstyle/jdk-17/suppressions.xml'
'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.4/checkstyle/jdk-14/checkstyle.xml',
'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.4/checkstyle/jdk-14/suppressions.xml'
Comment on lines +8 to +9
Copy link
Contributor

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?

Copy link
Contributor

@dulajdilshan dulajdilshan Nov 21, 2025

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.

])
dest buildDir
overwrite false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public enum NodeKind {
NAMED_ARG_MATCH_PATTERN,
SIMPLE_MATCH_PATTERN,

/* Binding patterns*/
/* Binding patterns */
WILDCARD_BINDING_PATTERN,
CAPTURE_BINDING_PATTERN,
LIST_BINDING_PATTERN,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change

Copy link
Author

Choose a reason for hiding this comment

The 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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ public String toString() {
return "BLangResourceFunction: " + super.toString();
}

@Override
public NodeKind getKind() {
return NodeKind.RESOURCE_FUNC;
}

public void setRestPathParam(BLangSimpleVariable restParam) {
this.restPathParam = restParam;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ error.cannot.use.field.access.to.access.a.remote.method=\
error.invokable.must.return=\
this {0} must return a result

error.invokable.must.return.function=\
this function must return a result

error.main.should.be.public=\
the ''main'' function should be public

Expand Down
Binary file not shown.

This file was deleted.

27 changes: 0 additions & 27 deletions distribution/libs/build.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion distribution/zip/jballerina-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,4 @@ publishing {
tasks.createZip.dependsOn(':ballerina-io-internal:jar')
tasks.createZip.dependsOn(':ballerina-io-internal:copyInteropImports')
tasks.createDistribution.dependsOn(':ballerina-io-internal:jar')
tasks.createDistribution.dependsOn(':ballerina-io-internal:copyInteropImports')
tasks.createDistribution.dependsOn(':ballerina-io-internal:copyInteropImports')
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ org.gradle.workers.max=3
org.gradle.vfs.watch=false
systemProp.scan.capture-build-logging=false
systemProp.scan.capture-test-logging=false
org.gradle.internal.test.console=plain

version=2201.14.0-SNAPSHOT
group=org.ballerinalang
Expand Down
8 changes: 8 additions & 0 deletions project/.devcontainer.json
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"]
}
}
}
11 changes: 11 additions & 0 deletions project/.gitignore
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
8 changes: 8 additions & 0 deletions project/Ballerina.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
10 changes: 10 additions & 0 deletions project/main.bal
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
}
}
}
8 changes: 8 additions & 0 deletions test.bal
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
}
}
}
10 changes: 10 additions & 0 deletions testCase/test_case.bal
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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testProjectWithDepsToml() throws BallerinaTestException {
String projectPath = projectsRoot.resolve("projectWithOneToolWithDepsToml").toString();
String output = balClient.runMainAndReadStdOut("build", new String[]{projectPath},
new HashMap<>(), userDir, true);
Assert.assertTrue(output.contains("dummytoolA 1.2.1"), output);
Assert.assertTrue(output.contains("dummytoolA 1.2.0"), output);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public void mavenResolvingTest() throws BallerinaTestException, IOException {
// delete the platform lib directory
deleteFiles(this.projectPath.resolve("target").resolve("platform-libs"));

String mvnBuildMsg = "target/bin/tests.jar";
String mvnBuildMsg = "target\\bin\\tests.jar";
LogLeecher mvnBuildLeecher = new LogLeecher(mvnBuildMsg);
balClient.runMain("build", new String[]{}, envVariables, new String[]{},
new LogLeecher[]{mvnBuildLeecher}, projectPath.toString());
mvnBuildLeecher.waitForText(5000);
mvnBuildLeecher.waitForText(50000);
// delete the platform lib directory
deleteFiles(this.projectPath.resolve("target").resolve("platform-libs"));

Expand Down
Loading
Loading