[nem-bug] [Nemerle 0000719]: NotNull doesn't work with generic function parameters

feedback at nemerle.org feedback at nemerle.org
Fri Jul 14 12:33:10 CEST 2006


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=719> 
======================================================================
Reported By:                aleksey
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   719
Category:                   The Macro Library
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             07-14-2006 06:36 CEST
Last Modified:              07-14-2006 12:33 CEST
======================================================================
Summary:                    NotNull doesn't work with generic function
parameters
Description: 
Example:
def foo[T]([NotNull] bar : T) : void
{
    // some code
}

Error message:
error: comparing a value type T.722 to System.Object (a `null' literal?)
with reference equality

Minimal example without NotNull macro:
def foo[T](bar : T) : bool
{
	bar != null
	// the only workaround which seems to work
	// (bar : object) != null
}

C# example which works:
static class Foobar
{
	static bool Foo<T>(T bar)
	{
		return bar != null;
	}

	static void Main()
	{
		System.Console.WriteLine(Foo(20));
	}
}
======================================================================

----------------------------------------------------------------------
 nazgul - 07-14-06 12:33 
----------------------------------------------------------------------
I don't think we should allow comparison to null for values, which may be
value types. If you added ': class' contraint, it should then work.

Issue History
Date Modified  Username       Field                    Change              
======================================================================
07-14-06 06:36 aleksey        New Issue                                    
07-14-06 12:33 nazgul         Note Added: 0001367                          
======================================================================




More information about the bugs mailing list