Page 1 of 1

compiler error with default/optional variables

PostPosted: Sat Jan 18, 2014 4:35 am
by kobi7
Hi Charles, and everyone!

this code generates the errors at the bottom of the page.
cue init(view as IView<of TEnumParts>, options /#as Options#/ = Options.None)


if I type the options argument 'as Options', the errors don't appear (and everything compiles)
this seems to be coming from mono dealing with the generated csharp.

ps: I tried to reproduce with a minimal case, but it didn't appear there.
if you're interested let me know [kobi2187 at gmail] , and I'll send a zip file.

see you, kobi

Code: Select all
GardenController.cobra(12): error: The name "Class" does not exist in the current context
GardenController.cobra(12): error: The name "sh" does not exist in the current context
GardenController.cobra(12): error: The name "Controller" does not exist in the current context
GardenController.cobra(12): error: The name "name" does not exist in the current context
GardenController.cobra(12): error: The name "didStartBindInh" does not exist in the current context
GardenController.cobra(12): error: The name "isBindingInh" does not exist in the current context
GardenController.cobra(12): error: The name "didBindInh" does not exist in the current context
GardenController.cobra(12): error: The name "didBindInt" does not exist in the current context
GardenController.cobra(12): error: The name "didBindImp" does not exist in the current context
GardenController.cobra(12): error: The name "token" does not exist in the current context
GardenController.cobra(12): error: Mono.CSharp.DefaultParameterValueExpression ExprClass is Invalid after resolve
GardenController.cobra(12): error: The expression being assigned to optional parameter "options" must be a constant or default value
(0): error: Unhandled Exception:
(0): error:   at Mono.CSharp.Parameter.ApplyAttributes (IKVM.Reflection.Emit.MethodBuilder mb, IKVM.Reflection.Emit.ConstructorBuilder cb, Int32 index, Mono.CSharp.PredefinedAttributes pa) [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.ParametersCompiled.ApplyAttributes (IMemberContext mc, IKVM.Reflection.MethodBase builder) [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.Constructor.Emit () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.TypeDefinition.Emit () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.ClassOrStruct.Emit () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.Class.Emit () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.TypeDefinition.EmitContainer () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.ModuleContainer.EmitContainer () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.AssemblyDefinition.Emit () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
(0): error:   at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
(0): error: [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object

Build: 28 errors, 0 warnings

Re: compiler error with default/optional variables

PostPosted: Sat Jan 18, 2014 3:04 pm
by Charles
I'll take a look.

Re: compiler error with default/optional variables

PostPosted: Sat Jan 18, 2014 7:37 pm
by Charles
I can't reproduce. I sent you an email for the code.

Some things you could try to eliminate some variables:
-- Does the problem happen for ordinary methods or just initializers?
-- Does the problem happen if you eliminate the first argument?
-- Does the problem happen in non-generic classes?
-- Is Options.None an enum or a constant or something else? If you switch it, does the problem change?
-- Is Options nested in the same class as the initializer or outside of that class?

Also:
-- Are their multiple "Options" defined in other namespaces?
-- If you pass -kif to Cobra and open the remaining .cs file for that source code, what does the C# look like?