René's URL Explorer Experiment


Title: Improve type inference of array literals and foreach statement variables by SeeminglyScience · Pull Request #8100 · PowerShell/PowerShell · GitHub

Open Graph Title: Improve type inference of array literals and foreach statement variables by SeeminglyScience · Pull Request #8100 · PowerShell/PowerShell

X Title: Improve type inference of array literals and foreach statement variables by SeeminglyScience · Pull Request #8100 · PowerShell/PowerShell

Description: PR Summary Improve type inference for foreach statement variables by: Inferring strongly typed arrays from explicit array and array literal expressions when elements are of the same inferred type Fix detection of foreach variable declaration. The previous logic was to check if the variable expression's start offset was after the end offset of the foreach statement, which will never be true in the body Improve inference of what type the "Condition" of a foreach statement will enumerate as Here's some examples of scenarios that now work correctly: foreach ($i in 0, 1, 2) { $i. } # CompareTo GetType ToByte ToDecimal ToInt32 ToSingle ToUInt16 TryFormat # Equals GetTypeCode ToChar ToDouble ToInt64 ToString ToUInt32 # GetHashCode ToBoolean ToDateTime ToInt16 ToSByte ToType ToUInt64 foreach ($i in @{}.GetEnumerator()) { $i. } # Key Name Value Deconstruct Equals GetHashCode GetType ToString $dict = [System.Collections.Generic.Dictionary[string, string]]::new() foreach ($i in $dict.GetEnumerator()) { $i. } # Key Value Deconstruct Equals GetHashCode GetType ToString foreach ($i in $dict.GetEnumerator()) { $i.Key. } # Length GetType PadLeft ToChar ToLowerInvariant ToUpperInvariant # Clone GetTypeCode PadRight ToCharArray ToSByte Trim # CompareTo IndexOf Remove ToDateTime ToSingle TrimEnd # Contains IndexOfAny Replace ToDecimal ToString TrimStart # CopyTo Insert Split ToDouble ToType # EndsWith IsNormalized StartsWith ToInt16 ToUInt16 # Equals LastIndexOf Substring ToInt32 ToUInt32 # GetEnumerator LastIndexOfAny ToBoolean ToInt64 ToUInt64 # GetHashCode Normalize ToByte ToLower ToUpper Note: I specifically avoided testing for IEnumerable<> directly because some types like string are not enumerated by PowerShell. I know there's more types than string, if someone could point me to a full list of types that implement IEnumerable but PowerShell doesn't enumerate, I'll add in testing for that as well. Found it, I used PSEnumerableBinder for reference. PR Checklist PR has a meaningful title Use the present tense and imperative mood when describing your changes Summarized changes Change is not breaking Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header This PR is ready to merge and is not Work in Progress. If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready. User-facing changes Not Applicable OR User-facing Documentation needed Issue filed - Issue link: Testing - New and feature Not Applicable or can only be tested interactively OR Make sure you've added a new test if existing tests do not effectively test the code changed Add [feature] if the change is significant or affects feature tests

Open Graph Description: PR Summary Improve type inference for foreach statement variables by: Inferring strongly typed arrays from explicit array and array literal expressions when elements are of the same inferred type...

X Description: PR Summary Improve type inference for foreach statement variables by: Inferring strongly typed arrays from explicit array and array literal expressions when elements are of the same inferred type...

Opengraph URL: https://github.com/PowerShell/PowerShell/pull/8100

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:749d5d85-a9a5-712e-5ecd-e4cf0548a5f8
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9BA6:3337E9:2050E8:2D1F68:6AFD712E
html-safe-nonce39d6c7544257b2adce05fd80d25dbd606910aa180d3c1f7240dfce4e1a130e6a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkE2OjMzMzdFOToyMDUwRTg6MkQxRjY4OjZBRkQ3MTJFIiwidmlzaXRvcl9pZCI6IjE3NTk3NDA2OTgxNjYxMjg5NDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacaf038775868c1799e8270ec4a53adb8a086086c057d1ba05e136e1adf27b9671
hovercard-subject-tagpull_request:224565566
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/PowerShell/PowerShell/pull/8100/files
twitter:imagehttps://avatars.githubusercontent.com/u/24977523?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/24977523?s=400&v=4
og:image:altPR Summary Improve type inference for foreach statement variables by: Inferring strongly typed arrays from explicit array and array literal expressions when elements are of the same inferred type...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonee54006cf2b96d1ac260960edd10003132911469ccd1ec99c9803119fe2a4e032
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5be0bf2b8cf26f8897d31e6bc3c232d328b12a54
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/pull/8100/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fpull%2F8100%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fpull%2F8100%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/pull/8100/files
Reloadhttps://github.com/PowerShell/PowerShell/pull/8100/files
Reloadhttps://github.com/PowerShell/PowerShell/pull/8100/files
PowerShellhttps://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Codehttps://github.com/PowerShell/PowerShell
Issues1.3k (1.3k)https://github.com/PowerShell/PowerShell/issues
Pull requests365 (365)https://github.com/PowerShell/PowerShell/pulls
Discussionshttps://github.com/PowerShell/PowerShell/discussions
Actionshttps://github.com/PowerShell/PowerShell/actions
Projectshttps://github.com/PowerShell/PowerShell/projects
Security and quality3 (3)https://github.com/PowerShell/PowerShell/security
Insightshttps://github.com/PowerShell/PowerShell/insights
Sign up for GitHub https://github.com/signup?return_to=%2FPowerShell%2FPowerShell%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FPowerShell%2FPowerShell%2Fissues%2Fnew%2Fchoose
Travis Plunk (TravisEz13)https://github.com/TravisEz13
PowerShell:masterhttps://github.com/PowerShell/PowerShell/tree/master
SeeminglyScience:foreach-iterator-type-inferencehttps://github.com/SeeminglyScience/PowerShell/tree/foreach-iterator-type-inference
Conversation 15 https://github.com/PowerShell/PowerShell/pull/8100
Commits 10 https://github.com/PowerShell/PowerShell/pull/8100/commits
Checks 0 https://github.com/PowerShell/PowerShell/pull/8100/checks
Files changed https://github.com/PowerShell/PowerShell/pull/8100/files
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/8100/files
Improve type inference of array literals and foreach statement variables https://github.com/PowerShell/PowerShell/pull/8100/files#top
Show all changes 10 commits https://github.com/PowerShell/PowerShell/pull/8100/files
8e5036a Fix type inference for foreach statement variable SeeminglyScience Oct 21, 2018 https://github.com/PowerShell/PowerShell/pull/8100/commits/8e5036a8003f934d5b35abae639596286019e04e
038a9a5 Enhance type inference of array literals SeeminglyScience Oct 21, 2018 https://github.com/PowerShell/PowerShell/pull/8100/commits/038a9a56380fdb49ce2933ce6ca088a81a7cd0c2
735365f Enhance type inference of foreach variables SeeminglyScience Oct 21, 2018 https://github.com/PowerShell/PowerShell/pull/8100/commits/735365f971c482597c37fda140a90960ba4cfc0b
d0aca62 Fix interface checking for collection like SeeminglyScience Oct 21, 2018 https://github.com/PowerShell/PowerShell/pull/8100/commits/d0aca62543731aa76274d7f80e74fb0ac5abc23d
6f37637 Added tests SeeminglyScience Oct 21, 2018 https://github.com/PowerShell/PowerShell/pull/8100/commits/6f3763763b22356950d08a8c095ada95b25774ad
2942fa2 Use IEnumerable<> in type checks SeeminglyScience Oct 22, 2018 https://github.com/PowerShell/PowerShell/pull/8100/commits/2942fa2bc24fcd1c212c338496f456751890285a
2175392 Trigger build again due to github issue SeeminglyScience Oct 22, 2018 https://github.com/PowerShell/PowerShell/pull/8100/commits/21753927f1fca79c1e8121b04f4a9f1a988f972d
7328d3f Trigger build again SeeminglyScience Oct 22, 2018 https://github.com/PowerShell/PowerShell/pull/8100/commits/7328d3fb3fd968b096ab0c1df73eb35d979c3fbd
977accd Trigger build again SeeminglyScience Oct 26, 2018 https://github.com/PowerShell/PowerShell/pull/8100/commits/977accd15096d1a5451be844663192deffcc2401
ce6d7a8 Add method documentation per feedback SeeminglyScience Feb 10, 2019 https://github.com/PowerShell/PowerShell/pull/8100/commits/ce6d7a8721514332ebbb673d0836f84e0c351c61
Clear filters https://github.com/PowerShell/PowerShell/pull/8100/files
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/8100/files
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/8100/files
TypeInferenceVisitor.cs https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
TypeInference.Tests.ps1 https://github.com/PowerShell/PowerShell/pull/8100/files#diff-b13389ec5d0612aeee45773c528c7e68489b6ba4593b279c41f1421995f4aa09
https://github.com/PowerShell/PowerShell/blob/master/.github/CODEOWNERS#L49
src/System.Management.Automation/engine/parser/TypeInferenceVisitor.cshttps://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
View file https://github.com/SeeminglyScience/PowerShell/blob/ce6d7a8721514332ebbb673d0836f84e0c351c61/src/System.Management.Automation/engine/parser/TypeInferenceVisitor.cs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/PowerShell/PowerShell/pull/8100/{{ revealButtonHref }}
https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/8100/files
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/8100/files
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/8100/files
https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/8100/files
https://github.com/PowerShell/PowerShell/pull/8100/files#diff-30feea0794a0191c121a83e2fa60dbacf701dd9c5be6c4d57b1865cdee745d6b
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/8100/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.