tact-lang / tact

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

feat: prevent variable declaration from shadowing functions #323

Closed vitorpy closed 2 months ago

vitorpy commented 4 months ago

Closes #307

Just checking if this is a sensible approach to handle avoiding variable declarations from shadowing functions.

I'm guessing I should also avoid shadowing other identifiers, such as contract names? Also non-static functions I guess.

vitorpy commented 4 months ago

@anton-trunov Sorry, can you provide some guidance here on which cases this is expected to cover? ie. which test cases are missing?

vitorpy commented 3 months ago

@anton-trunov @novusnota Hey guys, should this be allowed?

image

novusnota commented 3 months ago

Hey guys, should this be allowed?

@vitorpy Tact doesn't have first-class functions, so we can allow such declarations, I think. Let's wait for input from @anton-trunov though.

anton-trunov commented 3 months ago

Tact doesn't have first-class functions, so we can allow such declarations

This is an instance of type-directed disambiguation and it's an opportunity to mess up. I say we go for simplicity and ban this, no shadowing should be allowed at this moment. I mean it's easier to ban some behavior and relax the restrictions in later language versions. And it's backwards compatible!

anton-trunov commented 3 months ago

@vitorpy Let's disallow let sender: Address = sender()