Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler Crash: MoveToImmutable can only be performed when Count equals Capacity #1102

Closed
smx-smx opened this issue Jan 31, 2023 · 1 comment
Assignees
Labels

Comments

@smx-smx
Copy link

smx-smx commented Jan 31, 2023

It looks like using the spread operator to build another array (PHP 7.4 feature/replacement for array_merge) always induces a compiler error, as reproducible by the following example:

<?php

$arr1 = ['a'];
$arr2 = [...$arr1, '1']; //<--this line triggers the compiler error
var_dump($arr2);

Compiler log (version 1.1.5):

C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error : MoveToImmutable can only be performed when Count equals Capacity. [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at System.Collections.Immutable.ImmutableArray`1.Builder.MoveToImmutable() [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindArrayItems(Item[] items) in D:\a\1\s\src\Peachpie.CodeAnalysis\Semantics\Semant
icsBinder.cs:line 1130 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindArrayEx(ArrayEx x, BoundAccess access) in D:\a\1\s\src\Peachpie.CodeAnalysis\Se
mantics\SemanticsBinder.cs:line 1030 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpressionCore(Expression expr, BoundAccess access) in D:\a\1\s\src\Peachpie.Co
deAnalysis\Semantics\SemanticsBinder.cs:line 527 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpression(Expression expr, BoundAccess access) in D:\a\1\s\src\Peachpie.CodeAn
alysis\Semantics\SemanticsBinder.cs:line 509 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindAssignEx(AssignEx expr, BoundAccess access) in D:\a\1\s\src\Peachpie.CodeAnalys
is\Semantics\SemanticsBinder.cs:line 1411 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpressionCore(Expression expr, BoundAccess access) in D:\a\1\s\src\Peachpie.Co
deAnalysis\Semantics\SemanticsBinder.cs:line 532 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpression(Expression expr, BoundAccess access) in D:\a\1\s\src\Peachpie.CodeAn
alysis\Semantics\SemanticsBinder.cs:line 509 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindStatementCore(Statement stmt) in D:\a\1\s\src\Peachpie.CodeAnalysis\Semantics\S
emanticsBinder.cs:line 351 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindStatement(Statement stmt) in D:\a\1\s\src\Peachpie.CodeAnalysis\Semantics\Seman
ticsBinder.cs:line 344 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindWholeStatement(Statement stmt) in D:\a\1\s\src\Peachpie.CodeAnalysis\Semantics\
SemanticsBinder.cs:line 342 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor.Add(Statement stmt) in D:\a\1\s\src\Peachpie.CodeAnalysis\Semantics\Graph\Buil
derVisitor.cs:line 209 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor.VisitExpressionStmt(ExpressionStmt x) in D:\a\1\s\src\Peachpie.CodeAnalysis\Se
mantics\Graph\BuilderVisitor.cs:line 534 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Devsense.PHP.Syntax.Ast.ExpressionStmt.VisitMe(TreeVisitor visitor) [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Devsense.PHP.Syntax.TreeVisitor.VisitElement(ILangElement element) [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.EnumeratorExtension.ForEach[T](IEnumerable`1 enumerable, Action`1 func) in D:\a\1\s\src\Peachpie.CodeAnalysis
\Utilities\EnumeratorExtension.cs:line 62 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor..ctor(IList`1 statements, SemanticsBinder binder) in D:\a\1\s\src\Peachpie.Cod
eAnalysis\Semantics\Graph\BuilderVisitor.cs:line 176 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor.Build(IList`1 statements, SemanticsBinder binder) in D:\a\1\s\src\Peachpie.Cod
eAnalysis\Semantics\Graph\BuilderVisitor.cs:line 192 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Semantics.Graph.ControlFlowGraph..ctor(IList`1 statements, SemanticsBinder binder) in D:\a\1\s\src\Peachpie.C
odeAnalysis\Semantics\Graph\ControlFlowGraph.cs:line 125 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.Symbols.SourceRoutineSymbol.get_ControlFlowGraph() in D:\a\1\s\src\Peachpie.CodeAnalysis\Symbols\Source\Sourc
eRoutineSymbol.cs:line 52 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at Pchp.CodeAnalysis.SourceCompiler.EnqueueRoutine(SourceRoutineSymbol routine) in D:\a\1\s\src\Peachpie.CodeAnalysis\Compilation\
SourceCompiler.cs:line 119 [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at System.Threading.Tasks.Parallel.<>c__DisplayClass44_0`2.<PartitionerForEachWorker>b__1(IEnumerator& partitionState, Int32 timeo
ut, Boolean& replicationDelegateYieldedBeforeCompletion) [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error : --- End of stack trace from previous location --- [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at System.Threading.Tasks.Parallel.<>c__DisplayClass44_0`2.<PartitionerForEachWorker>b__1(IEnumerator& partitionState, Int32 timeo
ut, Boolean& replicationDelegateYieldedBeforeCompletion) [D:\peachpie_bug\Website\Website.msbuildproj]
C:\Users\user\.nuget\packages\peachpie.net.sdk\1.1.5\build\Peachpie.NET.Core.Sdk.targets(245,5): error :    at System.Threading.Tasks.TaskReplicator.Replica.Execute() [D:\peachpie_bug\Website\Website.msbuildproj]

The build failed. Fix the build errors and run again.
@smx-smx smx-smx changed the title MoveToImmutable can only be performed when Count equals Capacity Compiler Crash: MoveToImmutable can only be performed when Count equals Capacity Jan 31, 2023
@jakubmisek
Copy link
Member

thanks!

You're right, also this feature is not supported yet, and as a consequence it crashes the compiler

@jakubmisek jakubmisek self-assigned this May 4, 2024
jakubmisek added a commit that referenced this issue May 4, 2024
jakubmisek added a commit that referenced this issue May 4, 2024
jakubmisek added a commit that referenced this issue May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants