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 bad sad error in SemanticAnalyzer #42796

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mindula
Copy link
Contributor

@mindula mindula commented May 22, 2024

Purpose

$title.

Fixes #41101

Approach

Describe how you are implementing the solutions along with the design details.

Samples

Provide high-level details about the samples related to this feature.

Remarks

List any other known issues, related PRs, TODO items, or any other notes related to the PR.

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

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

codecov bot commented May 22, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 77.26%. Comparing base (0849031) to head (94f32c2).
Report is 148 commits behind head on master.

Files Patch % Lines
.../compiler/semantics/analyzer/SemanticAnalyzer.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #42796   +/-   ##
=========================================
  Coverage     77.26%   77.26%           
- Complexity    51302    51303    +1     
=========================================
  Files          2929     2929           
  Lines        204423   204423           
  Branches      26668    26668           
=========================================
+ Hits         157938   157940    +2     
+ Misses        37896    37894    -2     
  Partials       8589     8589           

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

@@ -1876,7 +1876,8 @@ private void handleDeclaredWithVar(BLangVariable variable, AnalyzerData data) {
handleWildCardBindingVariable(simpleVariable, currentEnv);

long ownerSymTag = currentEnv.scope.owner.tag;
if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE || (ownerSymTag & SymTag.LET) == SymTag.LET) {
if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE || (ownerSymTag & SymTag.LET) == SymTag.LET ||
(ownerSymTag & SymTag.PACKAGE) == SymTag.PACKAGE) {
Copy link
Member

Choose a reason for hiding this comment

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

If the variable is in the package scope, we define those variables in the symbol enter. Here, what we define are variables within functions, and the variables' owner becomes let. In the following scenario, the owner tag should also be equal to let.

In the current implementation, we set the owner as package instead of let. This is the root cause of the issue.

type Student record {|
    string fname;
    string lname;
    int id;
|};

Student[] students = [];

var v1 = from var st in students
    let var name = st.fname + st.lname
    select name;

function testModuleLevelLetClause() {
    var v2 = from var st in students
        let var name = st.fname + st.lname
        select name;
}

@chiranSachintha
Copy link
Member

@mindula It's better to change the title to reflect the specific issue we are fixing. As we tag these issues in the release notes, this will provide better understanding to users when they check for changes in the new update.

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 Jun 10, 2024
@mindula mindula removed the Stale label Jun 12, 2024
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.

[Bug]: Bad sad error in SemanticAnalyzer
2 participants