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

strange behavior with unused variables #5370

Closed
Anton-4 opened this issue May 3, 2023 · 3 comments
Closed

strange behavior with unused variables #5370

Anton-4 opened this issue May 3, 2023 · 3 comments

Comments

@Anton-4
Copy link
Contributor

Anton-4 commented May 3, 2023

expect
    patternMatch = \input ->
        when input is
            [Fo, Bar, Baz] -> Bingo
            _ -> Other

    first = (patternMatch [Fo, Bar, Baz] == Bingo)
    #second = (patternMatch [Fo, Bar, Baz, D] != Bingo)

    first

This passes with roc test, but this doesn't:

expect
    patternMatch = \input ->
        when input is
            [Fo, Bar, Baz] -> Bingo
            _ -> Other

    first = (patternMatch [Fo, Bar, Baz] == Bingo)
    second = (patternMatch [Fo, Bar, Baz, D] != Bingo)

    first

Output:

── EXPECT FAILED ─ ...os/examples/examples/PatternMatching/PatternMatching.roc ─

This expectation failed:

24│>  expect
25│>      patternMatch = \input ->
26│>          when input is
27│>              [Fo, Bar, Baz] -> Bingo
28│>              _ -> Other
29│>
30│>      first = (patternMatch [Fo, Bar, Baz] == Bingo)
31│>      second = (patternMatch [Fo, Bar, Baz, D] != Bingo)
32│>
33│>      first

When it failed, these variables had these values:

first : Bool
first = Bool.false

second : Bool
second = Bool.true



1 failed and 0 passed in 230 ms.

Note that second is not used so it is not supposed to change anything 😄 .

@ayazhafiz this error was introduced with PR #5317, or commit 12b2f7e

@ayazhafiz
Copy link
Sponsor Member

This is due to #5354

@JRI98
Copy link
Contributor

JRI98 commented Feb 6, 2024

No longer reproduces

@Anton-4
Copy link
Contributor Author

Anton-4 commented Feb 6, 2024

Thanks @JRI98 :)

@Anton-4 Anton-4 closed this as completed Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants