Page 1 of 1

helping with error

PostPosted: Sun Jan 12, 2014 10:17 am
by kobi7
Hi guys, I don't know if this is the place for such questions. (charles, maybe add a folder for such discussions?)
I have a simple code that fails. I'm not sure if it's my oversight, or a problem in the compiler.
I'm using an enum as a generic variable, and when using it, the compiler can't find its fields.
Does this work for you? :
# I get ...[the filename]... (0,0): Error: Cannot find a definition for "Information" in "Parts" whose type is "Parts". (Controller)
def doInfo
data = SimpleData<of Parts>(Parts.Information, .infoMsg)

enum Parts

struct SimpleData<of TEnumParts>
is public

get part from var as TEnumParts
get data from var as Object

cue init(part as TEnumParts, data as Object)
_part, _data = part, data

Thanks alot!

Re: helping with error

PostPosted: Sun Jan 12, 2014 10:37 am
by nerdzero
Assuming you are using MD/XS, I wonder if this is the same issue you had before with the implicit namespace. Have you updated since Charles made the fix? Might need to update the add-in as well if you did. What happens if you clear out the namespace in the project options?

Re: helping with error

PostPosted: Sun Jan 12, 2014 6:29 pm
by Charles
Do you have any other declarations called "Parts" anywhere?

Re: helping with error

PostPosted: Tue Jan 14, 2014 1:58 am
by kobi7
Hey guys, thanks for the help.
sorry, i think i found the problem.
my declaration class Controller<of Parts>
was where "Parts" had already been.
later there was an enum Parts
so that's where the confusion was.

generic declaration vs. "replacing" that generic when instantiating. (used the same name for the template variable)
(and the second mistake: use a real type when subclassing)

so I renamed to
class GardenController<of TEnumParts> inherits Controller<of Parts>

I guess I never went this far into generics land... so when inheriting from a class, use a real type for that "father" class. (it's not an interface after all, it needs real data)

Thanks for participation and help, hope you enjoyed the debugging session :-) !!