zls icon indicating copy to clipboard operation
zls copied to clipboard

track comptime types

Open mfield opened this issue 1 year ago • 2 comments

Adds some tracking of comptime types.

changes formatting for comptime structs, e.g. HashMap(...) -> HashMap(i32,void). maybe just a preference of mine? but i like seeing it. could easily change the formatter back to ....

fixes:

  • repeated use of the same comptime function #1841
  • nested generic structs e.g. #1392

mfield avatar Jan 04 '25 21:01 mfield

sorry for the false start. saw something while reading the diff and made a small change last second without re-building :( new version is passing tests again!

mfield avatar Jan 07 '25 01:01 mfield

Thanks for the review. Finally had some time to try out your suggestions and got the two big ones working:

  • bound_type_params is removed
  • bound_params moved from BoundScope to ScopeWithHandle

I'm not terribly fond of my change to DeclWithHandle nor pushing and popping comptime_state from completions.zig. Would be down to iterate again there if you have any suggestions. The two-pass collectDeclarationsOfContainer then declToCompletion for each decl collected does make some sense to draw a nice line between analysis.zig and completions.zig so I wasn't sure how to keep comptime_state discovered during collectDeclarationsOfContainer available to declToCompletion...

mfield avatar Jan 19 '25 04:01 mfield

@mfield Do you plan to apply the suggested changes anytime soon? If not, I'd be happy to apply them myself. This PR is a very nice improvement that would be unfortunate to miss out on.

Techatrix avatar Mar 19 '25 17:03 Techatrix

Hi, so sorry, completely lost track of this.

I tried your approach to moving bound_type_params out of completions and into analysis. The usingnamespace case is problematic enough I've backed out of it as well. The difficulty, as I see it, is that resolving the type of a function is too shallow. The Type that comes back doesn't describe the types of the parameters or the return type. So you have to remember to apply the same bound_type_params context to any operations that involve the function type, e.g. firstParamIs.

I think I've applied all the other suggestions. Please let me know if I've missed any.

mfield avatar Mar 23 '25 23:03 mfield