tact-lang / tact-docs

Tact main documentation
https://docs.tact-lang.org
41 stars 36 forks source link

Variable scoping is not documented #191

Open anton-trunov opened 2 months ago

anton-trunov commented 2 months ago

For instance, is variable shadowing allowed?

novusnota commented 2 months ago

Shadowing is not allowed. And with recent fix of variable scoping bug in loops, the scope of a variable declared with let is one of the following curly-brace-enclosed syntaxes that most closely contains the let statement:

The scope of the persistent state variable is all the receiver, getter and internal function bodies of the contract/trait.

anton-trunov commented 2 months ago

We need var-scope tests in the compiler to make sure the docs say the truth: https://github.com/tact-lang/tact/issues/288

novusnota commented 2 months ago

Intrestingly enough, function shadowing is not allowed, but has inconsistent behavior:

anton-trunov commented 2 months ago

Shadowing is not allowed

We should definitely have test cases for all the cases listed below in https://github.com/tact-lang/tact-docs/issues/191#issuecomment-2073163857