crystal-ameba / ameba

A static code analysis tool for Crystal
https://crystal-ameba.github.io
MIT License
514 stars 35 forks source link

`Lint/UselessAssign` when using generics #446

Closed Blacksmoke16 closed 7 months ago

Blacksmoke16 commented 7 months ago
record Foo(T), id : T
[W] Lint/UselessAssign: Useless assignment to variable `id`
> record Foo(T), id : T
Sija commented 7 months ago

Cannot reproduce, are you sure you're using the latest ameba version?

Blacksmoke16 commented 7 months ago

Yes:

# NOTICE: This lockfile contains some overrides from shard.dev.yml
version: 2.0
shards:
  ameba:
    git: https://github.com/crystal-ameba/ameba.git
    version: 1.6.1+git.commit.b56d34715de61b6674e02e85affe3124a22fb418
Sija commented 7 months ago

And this snippet alone reproduces the issue for you?

Blacksmoke16 commented 7 months ago

Yes:

$ cat test.cr 
record Foo(T), id : T

$ ./bin/ameba test.cr 
Inspecting 1 file

F

test.cr:1:16
[W] Lint/UselessAssign: Useless assignment to variable `id`
> record Foo(T), id : T
                 ^----^

Finished in 21.16 milliseconds
1 inspected, 1 failure
Sija commented 7 months ago

Cannot reproduce, that's very weird 🤔

Blacksmoke16 commented 7 months ago

I can clone master, make, and run the file and still fails:

$ crystal --version
Crystal 1.10.1 (2023-10-25)

LLVM: 16.0.6
Default target: x86_64-pc-linux-gnu
Sija commented 7 months ago

While running make I'm getting:

make: Nothing to be done for `all'.

Probably has sth to do with #445 /cc @straight-shoota

I've been able to reproduce it though.

Blacksmoke16 commented 7 months ago

Well just run make clean all and that'll rebuild it fresh.

Sija commented 7 months ago

@Blacksmoke16 Tried that, same thing :(