v icon indicating copy to clipboard operation
v copied to clipboard

checker,cgen: fix duplicates in generic sumtype

Open MCausc78 opened this issue 2 years ago • 2 comments

  1. Fix https://github.com/vlang/v/issues/19159
  2. Add tests
PS D:\Games\Proekti\V\vl> type test.v
@[on_duplicate: 'thats sentinel lol'; notice_if_duplicate]
type Name[T] = string | int | T

fn main() {
        _ := Name[int](123)
}
PS D:\Games\Proekti\V\vl> .\v2 run test.v
test.v:5:7: notice: duplicate type: thats sentinel lol
    3 |
    4 | fn main() {
    5 |     _ := Name[int](123)
      |          ~~~~~~~~~~~~~~
    6 | }

Note: you can control, whether to raise a error, notice or ignore if user used type, which is present as T in generic sumtype

MCausc78 avatar Mar 01 '24 20:03 MCausc78

Stale

MCausc78 avatar Jul 29 '24 10:07 MCausc78

Sorry, we'll figure something out to merge this.

medvednikov avatar Jul 29 '24 23:07 medvednikov