DEVSENSE / phptools-docs

PHP Tools public content
Apache License 2.0
79 stars 10 forks source link

Odd loss of type #563

Closed tanzanite777 closed 4 months ago

tanzanite777 commented 4 months ago

Type: Bug

Side-effect of dealing with issues - more will be reported :D. A few type-loss issues that i fairly frequently encounter:

class Odd {
    function loadMaybe() : ?Odd { return null; }
    function update() : Odd { return $this; }
    function snafu() {
        // inspect types via hover

        // works as expected: $fine is Odd
        $fine = $this->loadMaybe() ?? new Odd();
        // something went wrong: $zzz is Odd, $yyy has no-known-type-info (!?)
        $zzz = $yyy = new Odd();
        // something went wrong: do not know what 'update' refers to from ($bbb) no-known-type-info (!?)
        $xxx = ($this->loadMaybe() ?? new Odd())->update();
        $aaa = ($bbb = $this->loadMaybe() ?? new Odd())->update();
    }
}

Not sure what exactly causes it - thous are the best/clearest examples i have found.

Extension version: 1.46.15409 VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:13:33.891Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (8 x 3600)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.88GB (5.64GB free)| |Process Argv|--crash-reporter-id adf79977-8c83-4303-918e-a7dfc5f31bf1| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 tftest:31042121 vscod805cf:30301675 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 showvideot:31016892 chatpanelc:31048052 dsvsc021:30996838 bdiig495:31013172 pythoncenvpt:31049070 fchga941:31046352 pythonprt:31047983 dwnewjupyter:31046869 fa862199:31048878 ```
jakubmisek commented 4 months ago

Thanks!

This is related to mouse hover, which shows the type information (incorrectly) as it was /before/ the assignment.

You can try checking the type with @trace doc tag:

$zzz = $yyy = new Odd();
/** @trace $yyy */

image

jakubmisek commented 4 months ago

fixed in the next update