[Mono-bugs] [Bug 541432] New: LINQ expression does not compile

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Sep 23 11:34:25 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=541432


           Summary: LINQ expression does not compile
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.0.x
          Platform: Other
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: novell at veniogames.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Development


Description of Problem: A LINQ expression in my code does not seem to compile
and throws an exception in the compiler. (There is nothing wrong with the
expression, it works correct in Visual C#.)


Steps to reproduce the problem:
Try to compile this. You need a database with the fields "Key", "Username" and
"Other". Mine is called PasswordData with a table PasswordValue. d is declared
as a DataView.

d = (from i in PasswordData.Tables["PasswordValue"].AsEnumerable()

                                  where (from s in text.Split(' ') where s !=
"" select s).Select((num, index) => (from a in (from s in text.Split(' ') where
s != "" select new Regex(".*" + Regex.Escape(s) + ".*",
RegexOptions.IgnoreCase)) select a.IsMatch(i.Field<String>("Key").Replace(" ",
""))).ToArray()[index] == true ||

                                                                              
(from a in (from s in text.Split(' ') where s != "" select new Regex(".*" +
Regex.Escape(s) + ".*", RegexOptions.IgnoreCase)) select
a.IsMatch(i.Field<String>("Other").Replace(" ", ""))).ToArray()[index] == true
||

                                                                              
(from a in (from s in text.Split(' ') where s != "" select new Regex(".*" +
Regex.Escape(s) + ".*", RegexOptions.IgnoreCase)) select
a.IsMatch(i.Field<String>("Username").Replace(" ", ""))).ToArray()[index] ==
true).All((f) => f == true)

                                  orderby (from a in (from s in text.Split(' ')
where s != "" select new Regex("\\b" + Regex.Escape(s) + "\\b",
RegexOptions.IgnoreCase)) select a.IsMatch(i.Field<String>("Key"))).Count((f)
=> f == true) descending,

                                          (from a in (from s in text.Split(' ')
where s != "" select new Regex("\\b" + Regex.Escape(s) + "\\b",
RegexOptions.IgnoreCase)) select a.IsMatch(i.Field<String>("Other"))).Count((f)
=> f == true) descending,

                                          (from a in (from s in text.Split(' ')
where s != "" select new Regex("\\b" + Regex.Escape(s) + ".*",
RegexOptions.IgnoreCase)) select a.IsMatch(i.Field<String>("Key"))).Count((f)
=> f == true) descending,

                                          (from a in (from s in text.Split(' ')
where s != "" select new Regex("\\b" + Regex.Escape(s) + ".*",
RegexOptions.IgnoreCase)) select a.IsMatch(i.Field<String>("Other"))).Count((f)
=> f == true) descending,

                                          (from a in (from s in text.Split(' ')
where s != "" select new Regex(".*" + Regex.Escape(s) + ".*",
RegexOptions.IgnoreCase)) select a.IsMatch(i.Field<String>("Key").Replace(" ",
""))).Count((f) => f == true) descending,

                                          (from a in (from s in text.Split(' ')
where s != "" select new Regex(".*" + Regex.Escape(s) + ".*",
RegexOptions.IgnoreCase)) select a.IsMatch(i.Field<String>("Other").Replace("
", ""))).Count((f) => f == true) descending,

                                          (from a in (from s in text.Split(' ')
where s != "" select new Regex("\\b" + Regex.Escape(s) + "\\b",
RegexOptions.IgnoreCase)) select
a.IsMatch(i.Field<String>("Username"))).Count((f) => f == true) descending,

                                          (from a in (from s in text.Split(' ')
where s != "" select new Regex("\\b" + Regex.Escape(s) + ".*",
RegexOptions.IgnoreCase)) select
a.IsMatch(i.Field<String>("Username"))).Count((f) => f == true) descending,

                                          (from a in (from s in text.Split(' ')
where s != "" select new Regex(".*" + Regex.Escape(s) + ".*",
RegexOptions.IgnoreCase)) select
a.IsMatch(i.Field<String>("Username").Replace(" ", ""))).Count((f) => f ==
true) descending,

                                  i.Field<String>("Key"),

                                  i.Field<String>("Username"),

                                  i.Field<String>("Other")

                                  select i).AsDataView();


Actual Results:

Compiler output. Please ignore the filenames.

Exception caught by the compiler while compiling:
   Block that caused the problem begin at:
/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(181,241):
                     Block being compiled:
[/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(181,241):,Internal(1,1):]
System.Exception: Expression Mono.CSharp.LocalVariableReference did not set its
type after Resolve
called from: Mono.CSharp.LocalVariableReference
Exception caught by the compiler while compiling:
   Block that caused the problem begin at:
/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(181,112):
                     Block being compiled:
[/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(181,126):,/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(183,254):]
System.Exception: Expression Mono.CSharp.LocalVariableReference did not set its
type after Resolve
called from: Mono.CSharp.LocalVariableReference
Exception caught by the compiler while compiling:
   Block that caused the problem begin at:
/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(181,35):
                     Block being compiled:
[/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(181,35):,Internal(1,1):]
System.Exception: Expression Mono.CSharp.LocalVariableReference did not set its
type after Resolve
called from: Mono.CSharp.LocalVariableReference
Exception caught by the compiler while compiling:
   Block that caused the problem begin at:
/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(167,14):
                     Block being compiled:
[/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(178,17):,/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(198,17):]
Mono.CSharp.InternalErrorException:
/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(181,35):
Internal compiler error at
/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(167,14)::
exception caught while emitting MethodBuilder [PasswordSaverCore::ui_Search]


Unhandled Exception: Mono.CSharp.InternalErrorException:
/media/sdk/Projects/PasswordSaver/PasswordSaverCore/PasswordSaverCore.cs(181,35):
---> System.Exception: Expression Mono.CSharp.LocalVariableReference did not
set its type after Resolve
called from: Mono.CSharp.LocalVariableReference
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.SimpleName.DoSimpleNameResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side, Boolean intermediate) [0x00000] 
  at Mono.CSharp.SimpleName.SimpleNameResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side, Boolean intermediate) [0x00000] 
  at Mono.CSharp.SimpleName.DoResolve (Mono.CSharp.EmitContext ec, Boolean
intermediate) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Argument.Resolve (Mono.CSharp.EmitContext ec, Location loc)
[0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Return.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ContextualReturn.DoResolve (Mono.CSharp.EmitContext ec)
[0x00000] 
  at Mono.CSharp.ExitStatement.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.EmitContext.ResolveTopBlock (Mono.CSharp.EmitContext
anonymous_method_host, Mono.CSharp.ToplevelBlock block, Mono.CSharp.Parameters
ip, IMethodData md, System.Boolean& unreachable) [0x00000] 
  --- End of inner exception stack trace ---
  at Mono.CSharp.AnonymousMethodExpression.Compatible (Mono.CSharp.EmitContext
ec, System.Type type) [0x00000] 
  at Mono.CSharp.AnonymousMethodExpression.ImplicitStandardConversionExists
(Mono.CSharp.EmitContext ec, System.Type delegate_type) [0x00000] 
  at Mono.CSharp.Convert.ImplicitConversionExists (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression expr, System.Type target_type) [0x00000] 
  at Mono.CSharp.MethodGroupExpr.IsArgumentCompatible (Mono.CSharp.EmitContext
ec, Modifier arg_mod, Mono.CSharp.Argument argument, Modifier param_mod,
System.Type parameter) [0x00000] 
  at Mono.CSharp.MethodGroupExpr.IsApplicable (Mono.CSharp.EmitContext ec,
System.Collections.ArrayList arguments, Int32 arg_count,
System.Reflection.MethodBase& method, System.Boolean& params_expanded_form)
[0x00000] 
  at Mono.CSharp.MethodGroupExpr.OverloadResolve (Mono.CSharp.EmitContext ec,
System.Collections.ArrayList& Arguments, Boolean may_fail, Location loc)
[0x00000] 
  at Mono.CSharp.ExtensionMethodGroupExpr.ResolveOverloadExtensions
(Mono.CSharp.EmitContext ec, System.Collections.ArrayList arguments,
Mono.CSharp.NamespaceEntry ns, Location loc) [0x00000] 
  at Mono.CSharp.ExtensionMethodGroupExpr.OverloadResolve
(Mono.CSharp.EmitContext ec, System.Collections.ArrayList& arguments, Boolean
may_fail, Location loc) [0x00000] 
  at Mono.CSharp.Linq.AQueryClause+QueryExpressionInvocation.DoResolveOverload
(Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Linq.QueryExpression.DoResolve (Mono.CSharp.EmitContext ec)
[0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side) [0x00000] 
  at Mono.CSharp.MemberAccess.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Assign.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.SimpleAssign.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext
ec) [0x00000] 
  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec)
[0x00000] 
  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.If.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.If.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.EmitContext.ResolveTopBlock (Mono.CSharp.EmitContext
anonymous_method_host, Mono.CSharp.ToplevelBlock block, Mono.CSharp.Parameters
ip, IMethodData md, System.Boolean& unreachable) [0x00000] 



Expected Results:

It should compile fine.

How often does this happen? 

Every time I try to compile this.

Additional Information:

Commenting out the LINQ section solves the problem although that breaks my
application. The LINQ expression could be written a lot simpler, but I need to
get the results as a DataView, and if I declare variables in LINQ this will
result in a projection of the query which will not work. (I'm using this to
filter search results.)

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list