FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.
https://docs.fuel.network/docs/sway/
Apache License 2.0
62.58k stars 5.37k forks source link

Global type inference (function signatures without types) #2886

Open Centril opened 2 years ago

Centril commented 2 years ago

Either for development purposes, or in general, we could add global type inference to Sway. For example, you could define a function:

fn foo(a, b) { a * b }

and a type signature could be inferred for foo.

Then we can decide either to emit the inferred type as an error, as a design decision. Or, we could allow the function foo as legal code.

Another related concept is introducing typed holes, like so:

fn foo(a: ?, b: ?) { a * b }
Centril commented 2 years ago

cc @emilyaherbert