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

Autocomplete should not insert parenthesis for function pointers #2012

Open
IntegratedQuantum opened this issue Aug 28, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@IntegratedQuantum
Copy link
Contributor

Current behavior

Screenshot at 2024-08-28 10-16-38
Screenshot at 2024-08-28 10-16-43
It's easy to miss the fact that zls inserted some extra parenthesis there, and the error message of the compiler can also be pretty obscure. Overall it's really annoying to deal with.

Obscure error from the above example
compiler/zig/lib/std/Thread.zig:1050:30: error: unable to evaluate comptime expression
        return tls_thread_id orelse {
               ~~~~~~~~~~~~~~^~~~~~
compiler/zig/lib/std/Thread.zig:589:52: note: called from here
                return LinuxThreadImpl.getCurrentId();
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
compiler/zig/lib/std/Thread.zig:277:29: note: called from here
    return Impl.getCurrentId();
           ~~~~~~~~~~~~~~~~~^~
compiler/zig/lib/std/Thread/Mutex.zig:80:47: note: called from here
        const current_id = Thread.getCurrentId();
                           ~~~~~~~~~~~~~~~~~~~^~
compiler/zig/lib/std/Thread/Mutex.zig:44:19: note: called from here
    self.impl.lock();
    ~~~~~~~~~~~~~~^~
src/game.zig:112:13: note: called from here
  mutex.lock();
  ~~~~~~~~~~^~
src/main.zig:593:50: note: called from here
 currentPoint.pos = game.Player.getEyePosBlocking();
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
src/main.zig:364:74: note: called from here
  .{.name = "pos", .key = c.GLFW_KEY_F9, .releaseAction = &storePosAndVel()},
                                                           ~~~~~~~~~~~~~~^~

Proposed improvement

Ideally the result type should be detected, but I think that goes beyond zls's capabilities.
Instead it could check if there is an ampersand in front of the function name, if there is then don't add the extra parenthesis.

@IntegratedQuantum IntegratedQuantum added the enhancement New feature or request label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant