ref #20846; give a deprecation message for overriding = hook (#21020)

give a deprecation message for overriding `=` hook
This commit is contained in:
ringabout 2022-12-05 14:13:51 +08:00 • committed by GitHub
commit 6f96c4bc96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -1881,6 +1881,8 @@ proc semOverride(c: PContext, s: PSym, n: PNode) =
if s.magic == mAsgn: return
incl(s.flags, sfUsed)
incl(s.flags, sfOverriden)
if name == "=":
message(c.config, n.info, warnDeprecated, "Overriding `=` hook is deprecated; Override `=copy` hook instead")
let t = s.typ
if t.len == 3 and t[0] == nil and t[1].kind == tyVar:
var obj = t[1][0]