Stop type aliases from inheriting sfUsed (#19861)
Fixes #18201 Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
This commit is contained in:
parent
68aeb4c1a6
commit
f7a13f62d6
2 changed files with 41 additions and 14 deletions
|
|
@ -1506,7 +1506,7 @@ proc assignType*(dest, src: PType) =
|
||||||
# this fixes 'type TLock = TSysLock':
|
# this fixes 'type TLock = TSysLock':
|
||||||
if src.sym != nil:
|
if src.sym != nil:
|
||||||
if dest.sym != nil:
|
if dest.sym != nil:
|
||||||
dest.sym.flags.incl src.sym.flags-{sfExported}
|
dest.sym.flags.incl src.sym.flags-{sfUsed, sfExported}
|
||||||
if dest.sym.annex == nil: dest.sym.annex = src.sym.annex
|
if dest.sym.annex == nil: dest.sym.annex = src.sym.annex
|
||||||
mergeLoc(dest.sym.loc, src.sym.loc)
|
mergeLoc(dest.sym.loc, src.sym.loc)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,27 @@ discard """
|
||||||
matrix: "--hint:all:off --hint:XDeclaredButNotUsed"
|
matrix: "--hint:all:off --hint:XDeclaredButNotUsed"
|
||||||
nimoutFull: true
|
nimoutFull: true
|
||||||
nimout: '''
|
nimout: '''
|
||||||
treportunused.nim(23, 10) Hint: 's1' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(51, 5) Hint: 'A' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(24, 10) Hint: 's2' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(52, 5) Hint: 'B' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(25, 10) Hint: 's3' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(55, 5) Hint: 'D' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(26, 6) Hint: 's4' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(56, 5) Hint: 'E' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(27, 6) Hint: 's5' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(59, 5) Hint: 'G' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(28, 7) Hint: 's6' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(60, 5) Hint: 'H' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(29, 7) Hint: 's7' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(64, 5) Hint: 'K' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(30, 5) Hint: 's8' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(65, 5) Hint: 'L' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(31, 5) Hint: 's9' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(31, 10) Hint: 's1' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(32, 6) Hint: 's10' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(32, 10) Hint: 's2' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(33, 6) Hint: 's11' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(33, 10) Hint: 's3' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(37, 3) Hint: 'v0.99' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(34, 6) Hint: 's4' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(38, 3) Hint: 'v0.99.99' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(35, 6) Hint: 's5' is declared but not used [XDeclaredButNotUsed]
|
||||||
|
treportunused.nim(36, 7) Hint: 's6' is declared but not used [XDeclaredButNotUsed]
|
||||||
|
treportunused.nim(37, 7) Hint: 's7' is declared but not used [XDeclaredButNotUsed]
|
||||||
|
treportunused.nim(38, 5) Hint: 's8' is declared but not used [XDeclaredButNotUsed]
|
||||||
|
treportunused.nim(39, 5) Hint: 's9' is declared but not used [XDeclaredButNotUsed]
|
||||||
|
treportunused.nim(40, 6) Hint: 's10' is declared but not used [XDeclaredButNotUsed]
|
||||||
|
treportunused.nim(41, 6) Hint: 's11' is declared but not used [XDeclaredButNotUsed]
|
||||||
|
treportunused.nim(45, 3) Hint: 'v0.99' is declared but not used [XDeclaredButNotUsed]
|
||||||
|
treportunused.nim(46, 3) Hint: 'v0.99.99' is declared but not used [XDeclaredButNotUsed]
|
||||||
'''
|
'''
|
||||||
action: compile
|
action: compile
|
||||||
"""
|
"""
|
||||||
|
|
@ -36,3 +44,22 @@ type s11 = type(1.2)
|
||||||
let
|
let
|
||||||
`v0.99` = "0.99"
|
`v0.99` = "0.99"
|
||||||
`v0.99.99` = "0.99.99"
|
`v0.99.99` = "0.99.99"
|
||||||
|
|
||||||
|
block: # bug #18201
|
||||||
|
# Test that unused type aliases raise hint XDeclaredButNotUsed.
|
||||||
|
type
|
||||||
|
A = int
|
||||||
|
B = distinct int
|
||||||
|
|
||||||
|
C = object
|
||||||
|
D = C
|
||||||
|
E = distinct C
|
||||||
|
|
||||||
|
F = string
|
||||||
|
G = F
|
||||||
|
H = distinct F
|
||||||
|
|
||||||
|
J = enum
|
||||||
|
Foo
|
||||||
|
K = J
|
||||||
|
L = distinct J
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue