@@ -16,7 +16,8 @@ MissingFile,
1616InvalidModuleName,
1717TypePiracy,
1818CannotDeclareConst,
19- InvalidRedefofConst)
19+ InvalidRedefofConst,
20+ NotEqDef)
2021
2122const LintCodeDescriptions = Dict {LintCodes,String} (IncorrectCallArgs => " Possible method call error." ,
2223 IncorrectIterSpec => " A loop iterator has been used that will likely error." ,
@@ -34,7 +35,8 @@ const LintCodeDescriptions = Dict{LintCodes,String}(IncorrectCallArgs => "Possib
3435 InvalidModuleName => " Module name matches that of its parent." ,
3536 TypePiracy => " An imported function has been extended without using module defined typed arguments." ,
3637 CannotDeclareConst => " Cannot declare constant; it already has a value." ,
37- InvalidRedefofConst => " Invalid redefinition of constant." )
38+ InvalidRedefofConst => " Invalid redefinition of constant." ,
39+ NotEqDef => " `!=` is defined as `const != = !(==)` and should not be overloaded. Overload `==` instead." )
3840
3941haserror (m:: Meta ) = m. error != = nothing
4042haserror (x:: EXPR ) = hasmeta (x) && haserror (x. meta)
@@ -489,9 +491,11 @@ function check_typeparams(x::EXPR)
489491end
490492
491493function check_for_pirates (x:: EXPR )
492- if CSTParser. defines_function (x) && hasbinding (x) && overwrites_imported_function ( bindingof (x))
494+ if CSTParser. defines_function (x)
493495 sig = CSTParser. rem_where_decl (CSTParser. get_sig (x))
494- if typof (sig) == CSTParser. Call
496+ if fname_is_noteq (CSTParser. get_name (sig))
497+ seterror! (x, NotEqDef)
498+ elseif typof (sig) == CSTParser. Call && hasbinding (x) && overwrites_imported_function (bindingof (x))
495499 for i = 2 : length (sig)
496500 if hasbinding (sig[i]) && bindingof (sig[i]). type isa Binding
497501 return
@@ -504,6 +508,18 @@ function check_for_pirates(x::EXPR)
504508 end
505509end
506510
511+ function fname_is_noteq (x)
512+ if x isa EXPR
513+ if typof (x) === CSTParser. OPERATOR && kindof (x) === CSTParser. Tokens. NOT_EQ
514+ return true
515+ elseif is_getfield_w_quotenode (x) && length (x[3 ]) == 2 && CSTParser. is_colon (x[3 ][1 ])
516+
517+ return fname_is_noteq (x[3 ][2 ])
518+ end
519+ end
520+ return false
521+ end
522+
507523function refers_to_nonimported_type (arg:: EXPR )
508524 if hasref (arg) && refof (arg) isa Binding
509525 return true
0 commit comments