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 same warning is reported multiple times in parametrized functions #1485

Open
hzeller opened this issue Jun 17, 2024 · 0 comments
Open

The same warning is reported multiple times in parametrized functions #1485

hzeller opened this issue Jun 17, 2024 · 0 comments
Labels
dslx:lsp DSLX language server/protocol implementation dslx DSLX (domain specific language) implementation / front-end enhancement New feature or request

Comments

@hzeller
Copy link
Member

hzeller commented Jun 17, 2024

Consider the following function that has a style violation of using a lower case bar instead of upper case BAR and the test which instantiates multiple versions of this function with different parameters:

pub fn foo<WIDTH:u32>(x: uN[WIDTH]) -> uN[WIDTH] {
  const bar = uN[WIDTH]:42;
  x + bar
}

#[test]
fn test_foo() {
  // Instantiate with different types
  assert_eq(foo(u7:2), u7:44);
  assert_eq(foo(u8:5), u8:47);
  assert_eq(foo(u9:100), u9:142);
}

What is ...

Running the tests now emits the very same warning at the same line of code with the same message, possibly due to being internally instantiated multiple times with different parameters. However, the output is exactly the same.

bazel run //xls/dslx:interpreter_main -- /tmp/foo.x
/tmp/foo.x:2:3-2:28
0001: pub fn foo<WIDTH:u32>(x: uN[WIDTH]) -> uN[WIDTH] {
0002:   const bar = uN[WIDTH]:42;
~~~~~~~~^-----------------------^ Standard style is SCREAMING_SNAKE_CASE for constant identifiers; got: `bar`
0003:   x + bar
0004: }
/tmp/foo.x:2:3-2:28
0001: pub fn foo<WIDTH:u32>(x: uN[WIDTH]) -> uN[WIDTH] {
0002:   const bar = uN[WIDTH]:42;
~~~~~~~~^-----------------------^ Standard style is SCREAMING_SNAKE_CASE for constant identifiers; got: `bar`
0003:   x + bar
0004: }
/tmp/foo.x:2:3-2:28
0001: pub fn foo<WIDTH:u32>(x: uN[WIDTH]) -> uN[WIDTH] {
0002:   const bar = uN[WIDTH]:42;
~~~~~~~~^-----------------------^ Standard style is SCREAMING_SNAKE_CASE for constant identifiers; got: `bar`
0003:   x + bar
0004: }

The same multitude of messages is also emitted in the language server...

... what should

These messages should be uniqified and only emitted once as it is exactly the same position and exactly the same error text.

@hzeller hzeller added enhancement New feature or request dslx DSLX (domain specific language) implementation / front-end dslx:lsp DSLX language server/protocol implementation labels Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dslx:lsp DSLX language server/protocol implementation dslx DSLX (domain specific language) implementation / front-end enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant