Bug 57796 - Compiler Crash instead of CS1621
Summary: Compiler Crash instead of CS1621
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 5.0.0 (2017-02)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2017-06-27 14:55 UTC by Jonathan Chambers
Modified: 2017-07-28 09:19 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Jonathan Chambers 2017-06-27 14:55:47 UTC
Try to compile the code below

csc: error CS1621: The yield statement cannot be used inside an anonymous method or lambda expression

mcs: crash

///
Unhandled Exception:
Mono.CSharp.InternalErrorException: Class1.cs(10,24): UnityCompilerCrasher.MyCoroutine() ---> System.NotSupportedException: Specified method is not supported.
  at Mono.CSharp.YieldBreak.CloneTo (Mono.CSharp.CloneContext clonectx, Mono.CSharp.Statement target) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Statement.Clone (Mono.CSharp.CloneContext clonectx) [0x0000c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Block.CloneTo (Mono.CSharp.CloneContext clonectx, Mono.CSharp.Statement t) [0x000b1] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Statement.Clone (Mono.CSharp.CloneContext clonectx) [0x0000c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.If.CloneTo (Mono.CSharp.CloneContext clonectx, Mono.CSharp.Statement t) [0x00019] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Statement.Clone (Mono.CSharp.CloneContext clonectx) [0x0000c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Block.CloneTo (Mono.CSharp.CloneContext clonectx, Mono.CSharp.Statement t) [0x000b1] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ParametersBlock.CloneTo (Mono.CSharp.CloneContext clonectx, Mono.CSharp.Statement t) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Statement.Clone (Mono.CSharp.CloneContext clonectx) [0x0000c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ParametersBlock.PerformClone (System.Collections.Generic.HashSet`1[Mono.CSharp.LocalVariable]& undeclaredVariables) [0x00013] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.AnonymousMethodExpression.CompatibleMethodBody (Mono.CSharp.ResolveContext ec, Mono.CSharp.TypeInferenceContext tic, Mono.CSharp.TypeSpec return_type, Mono.CSharp.TypeSpec delegate_type, System.Collections.Generic.HashSet`1[Mono.CSharp.LocalVariable]& undeclaredVariables) [0x00020] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.AnonymousMethodExpression.Compatible (Mono.CSharp.ResolveContext ec, Mono.CSharp.TypeSpec type) [0x00038] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.AnonymousMethodExpression.ImplicitStandardConversionExists (Mono.CSharp.ResolveContext ec, Mono.CSharp.TypeSpec delegate_type) [0x00034] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Convert.ImplicitConversionExists (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression expr, Mono.CSharp.TypeSpec target_type) [0x0002b] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.OverloadResolver.IsArgumentCompatible (Mono.CSharp.ResolveContext ec, Mono.CSharp.Argument argument, Mono.CSharp.Parameter+Modifier param_mod, Mono.CSharp.TypeSpec parameter) [0x00098] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.OverloadResolver.IsApplicable (Mono.CSharp.ResolveContext ec, Mono.CSharp.Arguments& arguments, System.Int32 arg_count, Mono.CSharp.MemberSpec& candidate, Mono.CSharp.IParametersMember pm, System.Boolean& params_expanded_form, System.Boolean& dynamicArgument, Mono.CSharp.TypeSpec& returnType, System.Boolean errorMode) [0x00647] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.OverloadResolver.ResolveMember[T] (Mono.CSharp.ResolveContext rc, Mono.CSharp.Arguments& args) [0x0010c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.MethodGroupExpr.OverloadResolve (Mono.CSharp.ResolveContext ec, Mono.CSharp.Arguments& args, Mono.CSharp.OverloadResolver+IErrorHandler cerrors, Mono.CSharp.OverloadResolver+Restrictions restr) [0x00058] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.DoResolveOverload (Mono.CSharp.ResolveContext ec) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.DoResolveInvocation (Mono.CSharp.ResolveContext ec) [0x00194] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.ResolveContext rc) [0x00007] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, Mono.CSharp.ResolveFlags flags) [0x000d0] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext rc) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Argument.Resolve (Mono.CSharp.ResolveContext ec) [0x00009] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Arguments.Resolve (Mono.CSharp.ResolveContext ec, System.Boolean& dynamic) [0x00019] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.DoResolveInvocation (Mono.CSharp.ResolveContext ec) [0x00096] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.ResolveContext rc) [0x00007] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, Mono.CSharp.ResolveFlags flags) [0x000d0] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext rc) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.BlockContext ec) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.ResolveStatement (Mono.CSharp.BlockContext bc) [0x00007] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext bc) [0x000dd] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ParametersBlock.Resolve (Mono.CSharp.BlockContext bc) [0x00094] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.StateMachineInitializer.DoResolve (Mono.CSharp.ResolveContext rc) [0x00015] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, Mono.CSharp.ResolveFlags flags) [0x000d0] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext rc) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Return.DoResolve (Mono.CSharp.BlockContext ec) [0x000c5] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ExitStatement.Resolve (Mono.CSharp.BlockContext bc) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext bc) [0x000dd] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ParametersBlock.Resolve (Mono.CSharp.BlockContext bc) [0x00094] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ToplevelBlock.Resolve (Mono.CSharp.BlockContext bc, Mono.CSharp.IMethodData md) [0x00016] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.TypeDefinition parent) [0x0004a] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.MethodOrOperator.Emit () [0x001ae] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Method.Emit () [0x00104] in <e2b1898fa6204f1aad390729b128a60c>:0
   --- End of inner exception stack trace ---
  at Mono.CSharp.Method.Emit () [0x00114] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.TypeDefinition.Emit () [0x00217] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ClassOrStruct.Emit () [0x0001d] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Class.Emit () [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.TypeDefinition.EmitContainer () [0x0000c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00018] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00007] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00018] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ModuleContainer.EmitContainer () [0x00085] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.AssemblyDefinition.Emit () [0x0008c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x0010e] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Driver.Compile () [0x002a8] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Driver.Main (System.String[] args) [0x0004c] in <e2b1898fa6204f1aad390729b128a60c>:0
[ERROR] FATAL UNHANDLED EXCEPTION: Mono.CSharp.InternalErrorException: Class1.cs(10,24): UnityCompilerCrasher.MyCoroutine() ---> System.NotSupportedException: Specified method is not supported.
  at Mono.CSharp.YieldBreak.CloneTo (Mono.CSharp.CloneContext clonectx, Mono.CSharp.Statement target) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Statement.Clone (Mono.CSharp.CloneContext clonectx) [0x0000c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Block.CloneTo (Mono.CSharp.CloneContext clonectx, Mono.CSharp.Statement t) [0x000b1] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Statement.Clone (Mono.CSharp.CloneContext clonectx) [0x0000c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.If.CloneTo (Mono.CSharp.CloneContext clonectx, Mono.CSharp.Statement t) [0x00019] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Statement.Clone (Mono.CSharp.CloneContext clonectx) [0x0000c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Block.CloneTo (Mono.CSharp.CloneContext clonectx, Mono.CSharp.Statement t) [0x000b1] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ParametersBlock.CloneTo (Mono.CSharp.CloneContext clonectx, Mono.CSharp.Statement t) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Statement.Clone (Mono.CSharp.CloneContext clonectx) [0x0000c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ParametersBlock.PerformClone (System.Collections.Generic.HashSet`1[Mono.CSharp.LocalVariable]& undeclaredVariables) [0x00013] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.AnonymousMethodExpression.CompatibleMethodBody (Mono.CSharp.ResolveContext ec, Mono.CSharp.TypeInferenceContext tic, Mono.CSharp.TypeSpec return_type, Mono.CSharp.TypeSpec delegate_type, System.Collections.Generic.HashSet`1[Mono.CSharp.LocalVariable]& undeclaredVariables) [0x00020] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.AnonymousMethodExpression.Compatible (Mono.CSharp.ResolveContext ec, Mono.CSharp.TypeSpec type) [0x00038] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.AnonymousMethodExpression.ImplicitStandardConversionExists (Mono.CSharp.ResolveContext ec, Mono.CSharp.TypeSpec delegate_type) [0x00034] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Convert.ImplicitConversionExists (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression expr, Mono.CSharp.TypeSpec target_type) [0x0002b] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.OverloadResolver.IsArgumentCompatible (Mono.CSharp.ResolveContext ec, Mono.CSharp.Argument argument, Mono.CSharp.Parameter+Modifier param_mod, Mono.CSharp.TypeSpec parameter) [0x00098] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.OverloadResolver.IsApplicable (Mono.CSharp.ResolveContext ec, Mono.CSharp.Arguments& arguments, System.Int32 arg_count, Mono.CSharp.MemberSpec& candidate, Mono.CSharp.IParametersMember pm, System.Boolean& params_expanded_form, System.Boolean& dynamicArgument, Mono.CSharp.TypeSpec& returnType, System.Boolean errorMode) [0x00647] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.OverloadResolver.ResolveMember[T] (Mono.CSharp.ResolveContext rc, Mono.CSharp.Arguments& args) [0x0010c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.MethodGroupExpr.OverloadResolve (Mono.CSharp.ResolveContext ec, Mono.CSharp.Arguments& args, Mono.CSharp.OverloadResolver+IErrorHandler cerrors, Mono.CSharp.OverloadResolver+Restrictions restr) [0x00058] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.DoResolveOverload (Mono.CSharp.ResolveContext ec) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.DoResolveInvocation (Mono.CSharp.ResolveContext ec) [0x00194] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.ResolveContext rc) [0x00007] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, Mono.CSharp.ResolveFlags flags) [0x000d0] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext rc) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Argument.Resolve (Mono.CSharp.ResolveContext ec) [0x00009] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Arguments.Resolve (Mono.CSharp.ResolveContext ec, System.Boolean& dynamic) [0x00019] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.DoResolveInvocation (Mono.CSharp.ResolveContext ec) [0x00096] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.ResolveContext rc) [0x00007] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, Mono.CSharp.ResolveFlags flags) [0x000d0] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext rc) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.BlockContext ec) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Invocation.ResolveStatement (Mono.CSharp.BlockContext bc) [0x00007] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext bc) [0x000dd] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ParametersBlock.Resolve (Mono.CSharp.BlockContext bc) [0x00094] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.StateMachineInitializer.DoResolve (Mono.CSharp.ResolveContext rc) [0x00015] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, Mono.CSharp.ResolveFlags flags) [0x000d0] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext rc) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Return.DoResolve (Mono.CSharp.BlockContext ec) [0x000c5] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ExitStatement.Resolve (Mono.CSharp.BlockContext bc) [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext bc) [0x000dd] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ParametersBlock.Resolve (Mono.CSharp.BlockContext bc) [0x00094] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ToplevelBlock.Resolve (Mono.CSharp.BlockContext bc, Mono.CSharp.IMethodData md) [0x00016] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.TypeDefinition parent) [0x0004a] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.MethodOrOperator.Emit () [0x001ae] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Method.Emit () [0x00104] in <e2b1898fa6204f1aad390729b128a60c>:0
   --- End of inner exception stack trace ---
  at Mono.CSharp.Method.Emit () [0x00114] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.TypeDefinition.Emit () [0x00217] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ClassOrStruct.Emit () [0x0001d] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Class.Emit () [0x00000] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.TypeDefinition.EmitContainer () [0x0000c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00018] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00007] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00018] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.ModuleContainer.EmitContainer () [0x00085] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.AssemblyDefinition.Emit () [0x0008c] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x0010e] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Driver.Compile () [0x002a8] in <e2b1898fa6204f1aad390729b128a60c>:0
  at Mono.CSharp.Driver.Main (System.String[] args) [0x0004c] in <e2b1898fa6204f1aad390729b128a60c>:0
///

// Test Case

using System;
using System.Collections;

public class UnityCompilerCrasher
{
    public delegate void MyCallback (string result);

    static void StartCoroutine (IEnumerator ie) { GC.KeepAlive (ie); }

    public IEnumerator MyCoroutine ()
    {
        StartCoroutine (AnotherCoroutine ((string result) =>
        {
            if (result.Equals ("dummy"))
            {
                // COMMENT THE NEXT LINE TO AVOID THE INTERNAL ERROR !!!
                yield break;
            }
        }));
        return null;
    }

    private IEnumerator AnotherCoroutine (MyCallback callback)
    {
        GC.KeepAlive (callback);
        yield break;
    }
}
Comment 1 Marek Safar 2017-07-28 09:19:08 UTC
Fixed in master and 2017-06

Note You need to log in before you can comment on or make changes to this bug.