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

Completion type inference infers from the first declaration in a document rather than the closest #18689

Closed
5 tasks done
SeeminglyScience opened this issue Nov 30, 2022 · 2 comments · Fixed by #18691
Closed
5 tasks done
Labels
Resolution-Fixed The issue is fixed. WG-Interactive-IntelliSense tab completion

Comments

@SeeminglyScience
Copy link
Collaborator

Prerequisites

Steps to reproduce

$script = 'function Test-Function {
    [hashtable] $myVar = @{ Completion = ''error'' }
}


[datetime] $myVar = Get-Date
$myVar.'

TabExpansion2 -inputScript $script -cursorColumn $script.Length | % CompletionMatches

Expected behavior

CompletionText        ListItemText         ResultType ToolTip
--------------        ------------         ---------- -------
Date                  Date                   Property datetime Date {get;}
Day                   Day                    Property int Day {get;}
DayOfWeek             DayOfWeek              Property System.DayOfWeek DayOfWeek {get;}
DayOfYear             DayOfYear              Property int DayOfYear {get;}
Hour                  Hour                   Property int Hour {get;}
Kind                  Kind                   Property System.DateTimeKind Kind {get;}
Microsecond           Microsecond            Property int Microsecond {get;}
Millisecond           Millisecond            Property int Millisecond {get;}
Minute                Minute                 Property int Minute {get;}
Month                 Month                  Property int Month {get;}
Nanosecond            Nanosecond             Property int Nanosecond {get;}
Second                Second                 Property int Second {get;}
Ticks                 Ticks                  Property long Ticks {get;}
TimeOfDay             TimeOfDay              Property timespan TimeOfDay {get;}
Year                  Year                   Property int Year {get;}
(etc)

Actual behavior

CompletionText     ListItemText      ResultType ToolTip
--------------     ------------      ---------- -------
Count              Count               Property int Count { get; }
IsFixedSize        IsFixedSize         Property bool IsFixedSize { get; }
IsReadOnly         IsReadOnly          Property bool IsReadOnly { get; }
IsSynchronized     IsSynchronized      Property bool IsSynchronized { get; }
Keys               Keys                Property System.Collections.ICollection Keys { get; }
SyncRoot           SyncRoot            Property System.Object SyncRoot { get; }
Values             Values              Property System.Collections.ICollection Values { get; }
Add(               Add                   Method void Add(System.Object key, System.Object value)…
Clear(             Clear                 Method void Clear()…
Clone(             Clone                 Method System.Object Clone()…
Contains(          Contains              Method bool Contains(System.Object key)…
ContainsKey(       ContainsKey           Method bool ContainsKey(System.Object key)
ContainsValue(     ContainsValue         Method bool ContainsValue(System.Object value)
CopyTo(            CopyTo                Method void CopyTo(array array, int arrayIndex)…
Equals(            Equals                Method bool Equals(System.Object obj)
GetEnumerator(     GetEnumerator         Method System.Collections.IDictionaryEnumerator GetEnumerator()…
GetHashCode(       GetHashCode           Method int GetHashCode()
GetObjectData(     GetObjectData         Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Ser…
GetType(           GetType               Method type GetType()
OnDeserialization( OnDeserialization     Method void OnDeserialization(System.Object sender)…
Remove(            Remove                Method void Remove(System.Object key)…
ToString(          ToString              Method string ToString()

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0
PSEdition                      Core
GitCommitId                    7.3.0
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@SeeminglyScience
Copy link
Collaborator Author

@MartinGC94 FYI in case one of your PRs already solves this 😁

@ghost ghost added the In-PR Indicates that a PR is out for the issue label Nov 30, 2022
@iSazonov iSazonov added the WG-Interactive-IntelliSense tab completion label Dec 20, 2022
@ghost ghost added Resolution-Fixed The issue is fixed. and removed Needs-Triage The issue is new and needs to be triaged by a work group. In-PR Indicates that a PR is out for the issue labels Jun 12, 2023
@ghost
Copy link

ghost commented Jun 29, 2023

🎉This issue was addressed in #18691, which has now been successfully released as v7.4.0-preview.4.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Fixed The issue is fixed. WG-Interactive-IntelliSense tab completion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants