ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.68k stars 753 forks source link

[Bug]: Debugger fails to list and evaluate `binding-pattern` variables #42411

Open lochana-chathura opened 8 months ago

lochana-chathura commented 8 months ago

Description

$subject.

Screenshot 2024-03-26 at 11 24 11

Steps to Reproduce

  1. checkout to this commit (https://github.com/ballerina-platform/nballerina/commit/9c70a7cf23d11d2fc568a56ef04a709eefc51456) in nballerina repo. Currently, it is the latest commit.
  2. Apply the following small patch to run only the record-t.bal test file.
    diff --git a/compiler/tests/testSuite.bal b/compiler/tests/testSuite.bal
    index 73a088aa..7468a12b 100644
    --- a/compiler/tests/testSuite.bal
    +++ b/compiler/tests/testSuite.bal
    @@ -154,6 +154,9 @@ function listSources(string initialChars) returns TestSuiteCases|io:Error|file:E
             if ext != ".bal" {
                 continue;
             }
    +            if base != "record-t" {
    +                continue;
    +            }
             int? dash = base.lastIndexOf("-");
             test:assertTrue(dash is int, "test file name must be in <name>-<kind>.bal format");
             string testKind = base.substring(1 + <int>dash);
  3. Add a debugging point at the following line. https://github.com/ballerina-platform/nballerina/blob/9c70a7cf23d11d2fc568a56ef04a709eefc51456/compiler/modules/types/mapping.bal#L166
  4. Run the following test in debugger mode. https://github.com/ballerina-platform/nballerina/blob/9c70a7cf23d11d2fc568a56ef04a709eefc51456/compiler/tests/testSuite.bal#L38

Affected Version(s)

2201.8.5 at least

OS, DB, other environment details and versions

MacOS

lochana-chathura commented 6 months ago
  • Also notice, variables that are listed already; pos, neg, and d, only the name is showing. Cannot expand those values and see what's inside.

Apparently, this is not specific to this scenario. Hence, extracted to a separate issue #42848

NipunaRanasinghe commented 2 weeks ago

Did some testing and this seems to be an issue in the Ballerina runtime, where the variable and line number tables not getting updated properly for binding pattern variables.

NipunaRanasinghe commented 2 weeks ago

Created https://github.com/ballerina-platform/ballerina-lang/issues/43623 to track the progress of the fixes from the compiler runtime side.