[Bug] Fix incorrect error message for resource functions (#43815)#44552
[Bug] Fix incorrect error message for resource functions (#43815)#44552chamod-malindu wants to merge 1 commit intoballerina-platform:masterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ReachabilityAnalyzer diagnostic message for resource functions has been updated to display "resource function" instead of "resource_func" when reporting the INVOKABLE_MUST_RETURN error, improving message clarity for resource function nodes. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Purpose
Fixes issue #43815 by replacing the internal AST enum string
"resource_func"with the correct language keyword"resource function"in theBCE2095compiler error message.Previously, if a resource function was missing a return statement, the compiler logged:
It will now correctly log:
Related Issues
Fixes #43815
Changes
DiagnosticErrorCode.INVOKABLE_MUST_RETURNargument so thatNodeKind.RESOURCE_FUNCtranslates to"resource function"rather than relying on the baretoLowerCase()enum string representation.Testing
This relies on existing
jballerina-unit-testsuites for diagnostic message validation. Submitting so CI can verify standard reachability tests against the updated string.Summary
This pull request fixes an incorrect compiler diagnostic message that was using an internal AST enum representation instead of the proper language keyword. The change improves the clarity and user-friendliness of error messages reported by the Ballerina compiler.
Changes
Modified file:
ReachabilityAnalyzer.javaUpdated the
INVOKABLE_MUST_RETURNdiagnostic message to display "resource function" instead of "resource_func" when a resource function is missing a return statement. The fix adds a specialized condition that checks if the function kind isNodeKind.RESOURCE_FUNCand maps it to the human-readable display string "resource function", while maintaining the existing behavior for other function types.Impact: Users will now see the correct, language-appropriate error message: "this resource function must return a result" instead of the previous internal representation "this resource_func must return a result".