ols icon indicating copy to clipboard operation
ols copied to clipboard

No semantic tokens inside `when` satements

Open thetarnav opened this issue 1 year ago • 6 comments

when ODIN_DEBUG {
	Foo :: struct {a, b, c: int}
	foo := Foo{}
}

Foo should have a struct or type semantic token, like it does outside of when statements.

thetarnav avatar Aug 06 '24 09:08 thetarnav

It's because there is no when stmt resolver. I would argue if the resolver returns false, then this should actually be grayed out.

DanielGavin avatar Aug 12 '24 10:08 DanielGavin

I would argue the opposite actually, ols can't know what it will resolve to, it has to account for both cases. ODIN_DEBUG will sometimes be true and sometimes false, depending on which build script I run. I don't have two editors open, one for debug and one for normal. I work on both at the same time, as should ols imo. Same for targets, if my project has both a cli and a browser game components, I don't want to "switch" between those.

thetarnav avatar Aug 12 '24 10:08 thetarnav

You still have to switch. Since if you want to use odin check it needs to know what your flags are. Otherwise it can give compiler errors.

DanielGavin avatar Aug 12 '24 11:08 DanielGavin

The default will be through profile defines.

I can add a config to go through all when stmt regardless, but just remember if you declare variables in both those whenclauses it'll go funky.

when ODIN_DEBUG {
  my_value: i32
}
else {
  my_value: i64
}

DanielGavin avatar Aug 12 '24 11:08 DanielGavin

You'd just see i64 instead of i32 in some cases. The flip side is not getting any lsp help where the target doesn't match.

Even if odin check is stuck at one target, ols can still be helpful, just like it is in _test files currently. I don't see compile errors there, but can still use autocomplete.

thetarnav avatar Aug 12 '24 12:08 thetarnav

I'll add a config for it either way. There are people that want one or the other.

DanielGavin avatar Aug 12 '24 12:08 DanielGavin