1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-10 15:09:04 +01:00
psalm/src/Psalm
Marco Pivetta e6600fea21 Better type inference and type checking for large union types used in array keys/values
Fixes #8983

This patch adds a basic test showing that, when reaching a union type with 30 elements
or more, Psalm used to fail with an error, because the large union type got simplified
into a more general type as part of performance optimizations done in `TypeCombiner::combine()`.

This means that a type like `array<1|2|3|(etcetera...)|100, mixed>` was internally
simplified to `array<int, mixed>`, after reaching 30 elements or more, which in turn
led to problems and confusing errors when large union types are in play.

Such union types are relatively common in lookup-table-alike value objects.

By removing the hardcoded call-time limit of `30` types to be combined, we hereby
rely on the default `TypeCombiner::combine()` limit of `500` items, which is more
healthy.

This may come with some performance implications, but it is worth trying out, for
now.

Further parameters passed to `TypeCombiner::combine()` that were already matching
parameter default values were also omitted from the call-sites.
2022-12-29 10:05:23 +01:00
..
CodeLocation Require trailing commas 2022-12-18 13:20:31 -06:00
Config Require trailing commas 2022-12-18 13:20:31 -06:00
Exception Require trailing commas 2022-12-18 13:20:31 -06:00
Internal Better type inference and type checking for large union types used in array keys/values 2022-12-29 10:05:23 +01:00
Issue Require trailing commas 2022-12-18 13:20:31 -06:00
Node Finalize virtual nodes 2022-02-07 02:05:47 +02:00
Plugin Add Codebase to remaining events 2022-12-20 17:18:50 -06:00
Progress Require trailing commas 2022-12-18 13:20:31 -06:00
Report Require trailing commas 2022-12-18 13:20:31 -06:00
SourceControl SlevomatCodingStandard.Commenting.DocCommentSpacing 2022-12-14 13:34:41 -06:00
Storage @psalm-api 2022-12-23 16:13:46 -06:00
Type Try 2022-12-25 19:11:54 +01:00
Aliases.php SlevomatCodingStandard.Commenting.DocCommentSpacing 2022-12-14 13:34:41 -06:00
Codebase.php Require trailing commas 2022-12-18 13:20:31 -06:00
CodeLocation.php Require trailing commas 2022-12-18 13:20:31 -06:00
Config.php Merge pull request #8987 from jack-worman/Always_check_unused_methods_and_properties 2022-12-28 15:20:48 +01:00
Context.php Require trailing commas 2022-12-18 13:20:31 -06:00
DocComment.php @psalm-api 2022-12-23 16:13:46 -06:00
ErrorBaseline.php Remove occurrences 2022-12-21 06:45:45 -06:00
FileBasedPluginAdapter.php Require trailing commas 2022-12-18 13:20:31 -06:00
FileManipulation.php Finalize (and internalize) more classes 2022-02-05 23:51:03 +02:00
FileSource.php Immutable unions (#8627) 2022-11-04 19:04:23 +01:00
IssueBuffer.php Add Codebase to remaining events 2022-12-20 17:18:50 -06:00
NodeTypeProvider.php
PluginFileExtensionsSocket.php Require trailing commas 2022-12-18 13:20:31 -06:00
PluginRegistrationSocket.php Use rector to add property typehints 2022-12-11 17:25:23 -06:00
Report.php Require trailing commas 2022-12-18 13:20:31 -06:00
StatementsSource.php
Type.php Add Codebase to remaining events 2022-12-20 17:18:50 -06:00