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

The error message is misleading when setting too many attributes #3542

Open
yegor256 opened this issue Nov 24, 2024 · 1 comment
Open

The error message is misleading when setting too many attributes #3542

yegor256 opened this issue Nov 24, 2024 · 1 comment

Comments

@yegor256
Copy link
Member

Consider this code:

sprintf
  "Hello, %s, your salary is %d"
  "Jeff"
  42

This will lead to error:

Can't overwrite the "λ" attribute

It's a very weird and misleading message. Apparently, it happens because sprintf doesn't have three void attributes, but only two. The right code is this:

sprintf
  "Hello, %s, your salary is %d"
  *
    "Jeff"
    42

I suggest adding this test method to PhDefaultTest:

    @Test
    void failsCorrectlyWhenTooManyAttributesPut() {
        MatcherAssert.assertThat(
            "the message explains what's going on",
            Assertions.assertThrows(
                ExAbstract.class,
                () -> new EOnumber().put(1, new Data.ToPhi(1)),
                "fails when trying to set attribute with too big position"
            ).getMessage(),
            Matchers.equalTo("there are no void attributes left, can't set the 1st one")
        );
    }

Let's make it pass.

@yegor256
Copy link
Member Author

@maxonfjvipon can you help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant