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

Improve the error message for invalid table key values #41992

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

nipunayf
Copy link
Contributor

Purpose

The current implementation of checking whether the table key value is a constant expression does not consider its nested expressions. Thus, this PR improves the implementation to precisely capture the value expression of key specifier 'k' must be a constant expression error message.

As mentioned in the specification, a constant-reference expression must reference a module-const-decl, and within a const-expr, any nested expression must also be a const-expr. The existing positive table key field value tests do not adhere to this condition, and this PR updates those test cases with the necessary changes. https://ballerina.io/spec/lang/master/#const-expr

Fixes #35043

Approach

The PR modifies the TypeChecker to improve its implementation of checking the constant expression for table key values.

Remarks

Check List

  • Read the Contributing Guide
  • 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

Copy link

codecov bot commented Jan 17, 2024

Codecov Report

Attention: Patch coverage is 83.87097% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 76.70%. Comparing base (9007aa5) to head (9901b72).
Report is 8 commits behind head on master.

Files Patch % Lines
...alang/compiler/semantics/analyzer/TypeChecker.java 83.87% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #41992      +/-   ##
============================================
- Coverage     76.71%   76.70%   -0.01%     
- Complexity    53062    53080      +18     
============================================
  Files          2882     2882              
  Lines        200002   200031      +29     
  Branches      26040    26048       +8     
============================================
+ Hits         153423   153443      +20     
- Misses        38132    38137       +5     
- Partials       8447     8451       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@LakshanWeerasinghe LakshanWeerasinghe added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Jan 18, 2024
Copy link

github-actions bot commented Feb 7, 2024

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Feb 7, 2024
@nipunayf nipunayf removed the Stale label Feb 8, 2024
Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Feb 23, 2024
@nipunayf nipunayf removed the Stale label Feb 25, 2024
KavinduZoysa
KavinduZoysa previously approved these changes Mar 4, 2024
@KavinduZoysa KavinduZoysa merged commit e9423ff into ballerina-platform:master Mar 4, 2024
17 of 18 checks passed
@nipunayf nipunayf added this to the 2201.9.0 milestone Mar 21, 2024
@nipunayf nipunayf added the Area/TypeChecker Type Checker related issues #Compiler label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/TypeChecker Type Checker related issues #Compiler 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.

No error when non-constant expressions are used as values for key fields
3 participants