Issue Details (XML | Word | Printable)

Key: BOO-748
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Rodrigo B. de Oliveira
Reporter: Jaroslaw Kowalski
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

Problem with typeof() in custom attributes

Created: 10/Aug/06 03:27 AM   Updated: 10/Aug/06 06:55 AM
Component/s: Boo.Lang.CodeDom, Compiler
Affects Version/s: None
Fix Version/s: 0.7.7

Time Tracking:
Not Specified

Environment: boo built from SVN trunk


 Description  « Hide
I have a code that fails to compile (boo from SVN):

======
import System;

class MyAttribute(Attribute):
def constructor(t):
pass

class K:
pass

[assembly:MyAttribute(typeof(K))]
======

BCE0015: Node 'K' has not been correctly processed.

When I replace typeof(K) with some string or integer literal - it
works.

When I replace typeof(K) with K, it works as well...

... BUT ...

The code presented is actually generated from a code generator that is based on CodeDOM. Boo's CodeGenerator produces "typeof(T)" for CodeTypeOfExpression(typeof(T)).

When I modify the CodeDOM provider to emit just "T" in this case:

Index: BooCodeGenerator.boo
===================================================================
— BooCodeGenerator.boo (revision 2308)
+++ BooCodeGenerator.boo (working copy)
@@ -92,6 +92,9 @@
protected override def GenerateBaseReferenceExpression(e as CodeBaseReferenceExpression) :
Output.Write("super")

+ protected override def GenerateTypeOfExpression(e as CodeTypeOfExpression) :
+ OutputType(e.Type)
+
protected override def GenerateCastExpression(e as CodeCastExpression) :
Output.Write("cast(")
OutputType(e.TargetType)

It works here but starts to fail in other places. The expression "typeof(K).Assembly" (written in C# syntax) becomes indistinguishable from K.Assembly which obviously fails, because K doesn't have a property named Assembly.

I'm not sure if this is a CodeDOM bug or compiler bug so I'm filing in both categories.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Rodrigo B. de Oliveira added a comment - 10/Aug/06 06:55 AM
Fixed in svn. Thanks for the report!