move-language / move

Apache License 2.0
2.25k stars 684 forks source link

[Bug] Inline functions do not properly check dropping values #955

Closed gerben-stavenga closed 1 year ago

gerben-stavenga commented 1 year ago

🐛 Bug

Currently inline functions do not type check on dropping values, ie.

struct OnlyMove { val: u64 } public inline fun drop_onlymove(x: OnlyMove) {}

compiles cleanly. Now if you use it will complain in the caller function, but I think this should be rejected in the module.

wrwg commented 1 year ago

This is by design. The entire abilty and borrow analysis happens after inlining. If this would not be the case, inline functions would be significantly less expressive. For example, you can have an inline function f(a: address): &R. But you can't have a non-inline function like this.