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

Multiple type definitions appear for same type #1041

Open
Jarred-Sumner opened this issue Mar 8, 2023 · 4 comments
Open

Multiple type definitions appear for same type #1041

Jarred-Sumner opened this issue Mar 8, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@Jarred-Sumner
Copy link
Contributor

Jarred-Sumner commented Mar 8, 2023

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 Jarred-Sumner added the bug Something isn't working label Mar 8, 2023
@SuperAuguste
Copy link
Member

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

@InKryption
Copy link
Contributor

Don't you mean ?type?

@SuperAuguste
Copy link
Member

#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 SuperAuguste added the good first issue Good for newcomers label Mar 17, 2023
@kassane
Copy link

kassane commented Mar 29, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants