zls icon indicating copy to clipboard operation
zls copied to clipboard

Multiple type definitions appear for same type

Open Jarred-Sumner opened this issue 2 years ago • 5 comments

Zig Version

0.11.0-dev.1863+a63134a4a

Zig Language Server Version

latest

Steps to Reproduce

Code:

var zig_str = if (value.isString())
    value.getZigString(globalThis)
else
    ZigString.Empty;

if (!zig_str.isAllASCII()) {
          // ^ cursor here
    zig_str = ZigString.Empty;
}

#1031 is a very nice improvement. It looks like there's a missing edgecase where when values branch but have the same type, they appear as two distinct types (both return ZigString here). Possibly related to that, I've noticed worse performance today compared to two days ago.

image

Expected Behavior

Show one type definition per unique type

Actual Behavior

Shows duplicate results

Jarred-Sumner avatar Mar 08 '23 06:03 Jarred-Sumner

Different but related issue with

const abc = if (1 == 1) SomeStruct else null;

Where it just assumes abc is SomeStruct or null (determined at comptime) and not ?SomeStruct... oops

SuperAuguste avatar Mar 08 '23 06:03 SuperAuguste

Don't you mean ?type?

InKryption avatar Mar 08 '23 11:03 InKryption

#1067 will also have this problem for now.

The fix is using a StringArrayHashMapUnmanaged based on the resolved node index or something which should remove duplicates.

SuperAuguste avatar Mar 17 '23 19:03 SuperAuguste

Same issue on:

    const lib = if (shared) 
         b.addSharedLibrary(.{ 
             .name = "winpthreads", 
             .optimize = optimize, 
             .target = target, 
             .version = .{ 
                 .major = 1, 
                 .minor = 0, 
                 .patch = 0, 
             }, 
         }) 
     else 
         b.addStaticLibrary(.{ 
             .name = "winpthreads", 
             .optimize = optimize, 
             .target = target, 
             .version = .{ 
                 .major = 1, 
                 .minor = 0, 
                 .patch = 0, 
             }, 
         });

The auto-completion mechanism stops working.

kassane avatar Mar 29 '23 23:03 kassane