Boo

Cannot use enumerations as attribute parameters

Details

  • Type: Bug Bug
  • Status: Reopened Reopened
  • Priority: Blocker Blocker
  • Resolution: Unresolved
  • Affects Version/s: 0.8.2
  • Fix Version/s: 0.9
  • Component/s: Emitter
  • Labels:
    None
  • Environment:
    Microsoft .NET 3.5
  • Testcase included:
    yes
  • Number of attachments :
    1

Description

The following program fails with an internal compiler error:

--------------------------------------------------------------------------------

enum Colors:
ORANGE
BLACK
MAGENTA

class ColorAttribute(System.Attribute):
def constructor(c as Colors):
pass

class Foo:
[Color(Colors.ORANGE)]
public bar as int

--------------------------------------------------------------------------------

The error is as follows:

attrtest.boo(12,10): BCE0055: Internal compiler error: Type must be a type provided by the runtime.
Parameter name: enumType.

Changing the "Colors" type in the attribute constructor to a plain object is a workaround for this problem.

Activity

Hide
Cedric Vivier added a comment -

Looks like it is a SRE gotcha. yay!
This works on Mono, and the crash is within SRE CustomAttributeBuilder.

Show
Cedric Vivier added a comment - Looks like it is a SRE gotcha. yay! This works on Mono, and the crash is within SRE CustomAttributeBuilder.
Hide
Cedric Vivier added a comment - - edited

edited:
the 'regression' was a typo! "def contructor" instead of "def constructor" huhu, I think we should get some warning about likely typos for constructor/destructor (after all this typo possibility does not exist in say C#)

Show
Cedric Vivier added a comment - - edited edited: the 'regression' was a typo! "def contructor" instead of "def constructor" huhu, I think we should get some warning about likely typos for constructor/destructor (after all this typo possibility does not exist in say C#)
Hide
Cedric Vivier added a comment -

Fixed in rev. 3167

Show
Cedric Vivier added a comment - Fixed in rev. 3167
Hide
Rodrigo B. de Oliveira added a comment -

Fixing c# integration issue caused this issue to reappear in 9f757fb991ff2fd08b4b864300624b5a6a42433d

Show
Rodrigo B. de Oliveira added a comment - Fixing c# integration issue caused this issue to reappear in 9f757fb991ff2fd08b4b864300624b5a6a42433d
Hide
Rodrigo B. de Oliveira added a comment -

The workaround for now is to define the enum in a separate assembly from the attribute.

Show
Rodrigo B. de Oliveira added a comment - The workaround for now is to define the enum in a separate assembly from the attribute.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: