[nem-bug] [Nemerle 0000649]: Can't provide generic constraint in quoted declaration

feedback at nemerle.org feedback at nemerle.org
Thu Apr 6 16:22:17 CEST 2006


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=649> 
======================================================================
Reported By:                OysterDva
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   649
Category:                   Compiler (parser/macros engine)
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             04-06-2006 16:00 CEST
Last Modified:              04-06-2006 16:22 CEST
======================================================================
Summary:                    Can't provide generic constraint in quoted
declaration
Description: 
The following code doesn't compile:

interface ISome {}
macro Test()
{
  _ = <[ decl: struct SomeValue[T] : ISome where T : ISome {} ]>;
  <[()]>
}
_ = 1

Error message is the following: "error : wrong number of parameters in
call, needed 2, got 3".

The problem is with generic constraint because the following code compiles
without any problems:

interface ISome {}
macro Test()
{
  _ = <[ decl: struct SomeValue[T] : ISome /* where T : ISome */ {} ]>;
  <[()]>
}
_ = 1
======================================================================

----------------------------------------------------------------------
 OysterDva - 04-06-06 16:22 
----------------------------------------------------------------------
Here is the possible workaround for the problem:

macro Test()
{
  def tydecl = <[ decl: struct SomeValue[T] : ISome /* where T : ISome */
{} ]>;
  
  // Set constraint outside of quoted declaration
  def typarms = tydecl.td.typarms;
  tydecl.td.typarms = Typarms(typarms.tyvars, [
Constraint(typarms.tyvars.Head, <[ ISome ]>) ]);
  
  <[()]>
}

However, workaround is ugly...

Issue History
Date Modified  Username       Field                    Change              
======================================================================
04-06-06 16:00 OysterDva      New Issue                                    
04-06-06 16:22 OysterDva      Note Added: 0001165                          
======================================================================




More information about the bugs mailing list