Skip to content

Commit

Permalink
address PR 15365 comments as of 11/26
Browse files Browse the repository at this point in the history
  • Loading branch information
brmataptos committed Dec 4, 2024
1 parent e479548 commit 9542fd0
Show file tree
Hide file tree
Showing 12 changed files with 6,683 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ impl<'a> ExpRewriterFunctions for LambdaLifter<'a> {
env.error(
&loc,
// TODO(LAMBDA)
"Lambdas expressions with `store` ability currently may only be a simple call to an existing `public` function (see release notes for details). This lambda expression requires the compiler to generate a `public` helper function, which might affect module upgradeability and is not yet supported."
"The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call."
);
return None;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,64 @@

Diagnostics:
warning: Unused parameter `f`. Consider removing or prefixing with an underscore: `_f`
┌─ tests/checking/inlining/function_name_shadowing.move:8:28
8 │ public inline fun quux(f:|u64, u64|u64, a: u64, b: u64): u64 {
│ ^
┌─ tests/checking/inlining/function_name_shadowing.move:20:28
20 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 {
│ ^

warning: Unused parameter `g`. Consider removing or prefixing with an underscore: `_g`
┌─ tests/checking/inlining/function_name_shadowing.move:20:45
20 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 {
│ ^

warning: Unused parameter `i`. Consider removing or prefixing with an underscore: `_i`
┌─ tests/checking/inlining/function_name_shadowing.move:20:57
20 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 {
│ ^

// -- Model dump before bytecode pipeline
module 0x42::OtherModule {
public fun g(a: u64,b: u64): u64 {
Add<u64>(a, b)
}
public fun h(a: u64,b: u64): u64 {
Add<u64>(Mul<u64>(2, a), b)
}
} // end 0x42::OtherModule
module 0x42::Test {
use 0x42::OtherModule::{g}; // resolved as: 0x42::OtherModule
public fun f(a: u64,b: u64): u64 {
Mul<u64>(a, b)
}
public inline fun quux(f: |(u64, u64)|u64,a: u64,b: u64): u64 {
Test::f(a, b)
public inline fun quux(f: |(u64, u64)|u64,g: |u64|u64,i: |u8|u8,a: u64,b: u64): u64 {
Mul<u64>(Mul<u64>(Test::f(a, b), OtherModule::g(a, b)), OtherModule::h(a, b))
}
public fun test_shadowing(): u64 {
Test::f(10, 2)
Mul<u64>(Mul<u64>(Test::f(10, 2), OtherModule::g(10, 2)), OtherModule::h(10, 2))
}
} // end 0x42::Test

// -- Sourcified model before bytecode pipeline
module 0x42::OtherModule {
public fun g(a: u64, b: u64): u64 {
a + b
}
public fun h(a: u64, b: u64): u64 {
2 * a + b
}
}
module 0x42::Test {
use 0x42::OtherModule;
public fun f(a: u64, b: u64): u64 {
a * b
}
public inline fun quux(f: |(u64, u64)|u64, a: u64, b: u64): u64 {
f(a, b)
public inline fun quux(f: |(u64, u64)|u64, g: |u64|u64, i: |u8|u8, a: u64, b: u64): u64 {
f(a, b) * OtherModule::g(a, b) * OtherModule::h(a, b)
}
public fun test_shadowing(): u64 {
f(10, 2)
f(10, 2) * OtherModule::g(10, 2) * OtherModule::h(10, 2)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
//# publish
module 0x42::OtherModule {
public fun g(a: u64, b: u64): u64 {
a + b
}

public fun h(a: u64, b: u64): u64 {
2 * a + b
}
}

//# publish
module 0x42::Test {
use 0x42::OtherModule::g;

public fun f(a: u64, b: u64): u64 {
a * b
}

public inline fun quux(f:|u64, u64|u64, a: u64, b: u64): u64 {
f(a, b)
public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 {
use 0x42::OtherModule::h;
f(a, b) * g(a, b) * h(a, b)
}

public fun test_shadowing(): u64 {
quux(|a, b| a - b, 10, 2)
quux(|a, b| a - b, |a| a + 2, |b| 255u8-b, 10, 2)
}
}

Expand Down
Loading

0 comments on commit 9542fd0

Please sign in to comment.