[Issue 4290] 'Fragile' opCmp/toHash signature errors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 20 06:04:20 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4290



--- Comment #6 from Steven Schveighoffer <schveiguy at yahoo.com> 2010-09-20 06:03:43 PDT ---
(In reply to comment #5)
> > Why should the D compiler refuse to compile them?
> 
> The D compiler has to disallow or warn against common traps.

But opCmp is a valid function!  I can still call it, even though it's not put
into the typeinfo.

> > This is probably a job for a lint-type tool.
> 
> If some bug may be found at compile-time and it's not too much hard to find it
> (example: it doesn't require flow analysis), then in my opinion it's a job of
> the (D) compiler to avoid the bug. Clang compiler designers seem to agree with
> me.

But it's not a bug!  opCmp is a valid symbol name for a function, and can be
called with the arguments you specify.  In fact, it even works with the
comparison operators.

There is nothing inherently special about opCmp.  We need to add special
notation conveying our intentions to the compiler (that it should be used in
the TypeInfo).  It's like refusing to compile a function because it's not an
english word.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list