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

erl_syntax_lib: annotate maybe_match_expr and else_expr correctly #8811

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

Conversation

MarkoMin
Copy link
Contributor

@MarkoMin MarkoMin commented Sep 13, 2024

maybe_match_expr and else_expr were not handled properly when annotating bindings. This was causing problem with ELS and this is currently preventing me to fix the issue. The problems were both false positive and false negative diagnostics.

This will probably cause problem in ELP too, so I'll kindly ping @robertoaloi @michalmuskala to take a look at this.

I didn't provide any test for this because it seems that erl_syntax_lib is not tested.

What one can do to test this PR is to build Erlang-LS from this PR and make sure that els_diagnostics_SUITE:bound_var_in_pattern_maybe/1 testcase passes. Testcase tests for both false negatives and false positives.

What I'm not completely sure is whether:

f() ->
maybe
    X ?= foo
else
    Err -> Err
end,
X.

should return bound variable or unsafe variable diagnostic? Currently it returns bound variable, but it probably should be unsafe. I'll add that to some testcase once I know what the desired behavior is.

Copy link
Contributor

github-actions bot commented Sep 13, 2024

CT Test Results

  2 files   13 suites   5m 6s ⏱️
112 tests 110 ✅ 2 💤 0 ❌
128 runs  126 ✅ 2 💤 0 ❌

Results for commit d97f353.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@rickard-green rickard-green added the team:VM Assigned to OTP team VM label Sep 16, 2024
@MarkoMin
Copy link
Contributor Author

Currently it returns bound variable, but it probably should be unsafe. I'll add that to some testcase once I know what the desired behavior is.

I just re-check and the code already results in "unsafe in maybe" error - which I think is correct behavior.

@bjorng
Copy link
Contributor

bjorng commented Oct 31, 2024

Thanks for your pull request.

Since this is a bug fix, I think it is appropriate to base it on the maint branch. If based on master, this fix will be released in Erlang/OTP 28, which is planned to be released next spring.

Could you also add a test to the syntax_tools_SUITE? We usually add a test when a bug is fixed. As an example of writing a test case for testing annotations, there is test_named_fun_bind_ann/1, which was added by you in 2022.

While you are it, please squash the commits into one commit. It would also be nice if you can put some of the information from the description of this PR into the commit message.

@bjorng bjorng added the waiting waiting for changes/input from author label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:VM Assigned to OTP team VM waiting waiting for changes/input from author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants