Hello, both VS 15.5 Preview 5 and the official VS 15.5 fail to compile my library using the C# 7.2 ref struct modifier in one of the structs I'm using.
Removing the ref struct modifier from the "FloatSpan2D" struct solves the issue.
If this is not a bug and that struct is actually being moved to the heap somehow/somewhere, it'd be useful to have some sort of warning to be able to fix the code error.
Otherwise, I hope this will help you pinpoint the cause of the issue.
Cheers!
System.InvalidOperationException: Unexpected value 'PointerElementAccess expression of Tensor type' of type 'System.String'
at Microsoft.CodeAnalysis.CSharp.Binder.GetValEscape(BoundExpression expr, UInt32 scopeOfTheContainingExpression)
at Microsoft.CodeAnalysis.CSharp.Binder.CheckInvocationArgMixing(SyntaxNode syntax, Symbol symbol, BoundExpression receiverOpt, ImmutableArray`1 parameters, ImmutableArray`1 argsOpt, ImmutableArray`1 argRefKindsOpt, ImmutableArray`1 argsToParamsOpt, UInt32 scopeOfTheContainingExpression, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindInvocationExpressionContinued(SyntaxNode node, SyntaxNode expression, String methodName, OverloadResolutionResult`1 result, AnalyzedArguments analyzedArguments, MethodGroup methodGroup, NamedTypeSymbol delegateTypeOpt, DiagnosticBag diagnostics, CSharpSyntaxNode queryClause)
at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodGroupInvocation(SyntaxNode syntax, SyntaxNode expression, String methodName, BoundMethodGroup methodGroup, AnalyzedArguments analyzedArguments, DiagnosticBag diagnostics, CSharpSyntaxNode queryClause, Boolean allowUnexpandedForm)
at Microsoft.CodeAnalysis.CSharp.Binder.BindInvocationExpression(SyntaxNode node, SyntaxNode expression, String methodName, BoundExpression boundExpression, AnalyzedArguments analyzedArguments, DiagnosticBag diagnostics, CSharpSyntaxNode queryClause, Boolean allowUnexpandedForm)
at Microsoft.CodeAnalysis.CSharp.Binder.BindInvocationExpression(InvocationExpressionSyntax node, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node, DiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node, DiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionStatement(CSharpSyntaxNode node, ExpressionSyntax syntax, Boolean allowsAnyExpression, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionStatement(ExpressionStatementSyntax node, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindPossibleEmbeddedStatement(StatementSyntax node, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.ForLoopBinder.BindForParts(ForStatementSyntax node, Binder originalBinder, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.ForLoopBinder.BindForParts(DiagnosticBag diagnostics, Binder originalBinder)
at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindPossibleEmbeddedStatement(StatementSyntax node, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindFixedStatementParts(FixedStatementSyntax node, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindFixedStatement(FixedStatementSyntax node, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindBlockParts(BlockSyntax node, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.BindMethodBody(MethodSymbol method, TypeCompilationState compilationState, DiagnosticBag diagnostics, ImportChain& importChain, Boolean& originalBodyNested)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass21_0.<CompileNamedTypeAsTask>b__0()
Hello, both VS 15.5 Preview 5 and the official VS 15.5 fail to compile my library using the C# 7.2 ref struct modifier in one of the structs I'm using.
Here's the link to the exact code that reproduces the error, just clone and try to compile the library "NeuralNetwork.NET":
https://github.com/Sergio0694/NeuralNetwork.NET/tree/VS_test_csc-compiler-error
Removing the ref struct modifier from the "FloatSpan2D" struct solves the issue.
If this is not a bug and that struct is actually being moved to the heap somehow/somewhere, it'd be useful to have some sort of warning to be able to fix the code error.
Otherwise, I hope this will help you pinpoint the cause of the issue.
Cheers!
This issue has been moved from https://developercommunity.visualstudio.com/content/problem/160134/cscexe-compiler-error-2146232797-with-ref-struct-c.html
VSTS ticketId: 533142
These are the original issue comments:
(no comments)
These are the original issue solutions:
(no solutions)
Edit by @OmarTawfik
Smaller repro:
It hits the following assert: