Forums

helping with error

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

helping with error

Postby kobi7 » Sun Jan 12, 2014 10:17 am

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)
.updateViewsPart(data)


enum Parts
Information
Configure
Processing
About


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!
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel

Re: helping with error

Postby nerdzero » Sun Jan 12, 2014 10:37 am

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?
nerdzero
 
Posts: 286
Location: Chicago, IL

Re: helping with error

Postby Charles » Sun Jan 12, 2014 6:29 pm

Do you have any other declarations called "Parts" anywhere?
Charles
 
Posts: 2510
Location: Los Angeles, CA

Re: helping with error

Postby kobi7 » Tue Jan 14, 2014 1:58 am

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 :-) !!

kobi
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel


Return to Discussion

Who is online

Users browsing this forum: No registered users and 9 guests

cron