Skip to content

Conversation

@Trinketer22
Copy link
Member

Impure inspection

Goal

To detect call to functions without impure specifier that are subject for removal by compiler.

Gotchas

Logic of dropping non-impure calls is fairly complicated.
In order for such call to stay compiled, it's result has to be referenced in other impure call or end up as a result of return statement.

Side effects

Grammar and declaration search fixes

Before, only single typed declaration was getting var_declaration type, therefore
inspections like UnusedVariable and any other kind of declaration/reference analysis was very limited.

Now all kind of declarations are supported:

;; single tensor
var (a, b) = foo();
;; tensor expression with declarations
(int a, int b) = foo()
;; nested tensors
var ((a, b, c), (d, e, f)) = (foo(), bar());
;; typed tuples
[int a, int b] = foo();
;; And mixes of those

BindResolver

In order to implement output tracking, bind resolver/destructor for FunC language is required,
and therefore it's part of this commit.

TODO

Chained assingment

var (a, b) = foo();
...
return a

Is treated as it won't dropped and that is correct
However, in case of

var (a, b) = foo();
...
int c = a + b;
return c;

Will currently state that foo is required to have impure specifier.
It is asking for the SSA, and that's probably the way to go.
I'm planing to add it

e2e test scenarios.

Currently only tested manually.

Trinketer22 added 3 commits November 12, 2025 23:17
This reverts commit 84d8cef.
Since theese files are dropped in master
@Trinketer22
Copy link
Member Author

Update

  • Bunch of bugs fixed
  • Some tests provided
  • Chained assignment is now supported

TODO

  • hole retrun type support in bindToReturnType
  • Issues with re-definitions within same scope and identifier->declaration resolution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant