tact-lang / tact

Tact compiler main repository
https://tact-lang.org
MIT License
275 stars 56 forks source link

Allow underscores as unused variable identifiers #338

Closed Gusarich closed 1 week ago

Gusarich commented 1 month ago

Closes #319

novusnota commented 2 weeks ago

As of now, it only works for foreach and catch, right?

Gusarich commented 2 weeks ago

As of now, it only works for foreach and catch, right?

Are there any other cases where we need it?

novusnota commented 2 weeks ago

Are there any other cases where we need it?

I don't think so, at least now. When we'll have #298 in the future, identifiers in let declarations would need them though.

anton-trunov commented 2 weeks ago

When we'll have https://github.com/tact-lang/tact/issues/298 in the future, identifiers in let declarations would need them though.

Actually, let-statements should have underscores even now. This can be used as a clear indication that some function gets called not for its return value but for its side-effects:

let _ : Foo = effectfulFun(x, y, z);

When we have a bit of type inference, the snippet above will become

let _ = effectfulFun(x, y, z);

In this case a static analyzer won't complain about unused values, whereas it should issue a warning for

effectfulFun(x, y, z);

if effectfulFun is a non-void function.

Gusarich commented 2 weeks ago

Added support for let-statements and also resolved all merge conflicts

Gusarich commented 2 weeks ago

resolved merge conflicts

Gusarich commented 1 week ago

@anton-trunov resolved merge conflicts yet again after merge of #198

Gusarich commented 1 week ago

@anton-trunov have a look