89 lines
1.9 KiB
Plaintext
89 lines
1.9 KiB
Plaintext
// Used include
|
|
include "Pair.aes"
|
|
// Unused include
|
|
include "Triple.aes"
|
|
|
|
namespace UnusedNamespace =
|
|
function f() = 1 + g()
|
|
|
|
// Used in f
|
|
private function g() = 2
|
|
|
|
// Unused
|
|
private function h() = 3
|
|
|
|
main contract Warnings =
|
|
|
|
type state = int
|
|
|
|
type unused_type = bool
|
|
|
|
entrypoint init(p) = Pair.fst(p) + Pair.snd(p)
|
|
|
|
stateful entrypoint negative_spend(to : address) = Chain.spend(to, -1)
|
|
|
|
entrypoint shadowing() =
|
|
let x = 1
|
|
let x = 2
|
|
x
|
|
|
|
entrypoint division_by_zero(x) = x / 0
|
|
|
|
stateful entrypoint unused_stateful() = 1
|
|
stateful entrypoint used_stateful(x : int) = put(x)
|
|
|
|
entrypoint unused_variables(unused_arg : int) =
|
|
let unused_var = 10
|
|
let z = 20
|
|
z
|
|
|
|
// Unused functions
|
|
function unused_function() = ()
|
|
function recursive_unused_function() = recursive_unused_function()
|
|
function called_unused_function1() = called_unused_function2()
|
|
function called_unused_function2() = called_unused_function1()
|
|
|
|
function rv() = 1
|
|
entrypoint unused_return_value() =
|
|
rv()
|
|
2
|
|
|
|
namespace FunctionsAsArgs =
|
|
function f() = g()
|
|
|
|
private function g() = h(inc)
|
|
private function h(fn : (int => int)) = fn(1)
|
|
|
|
// Passed as arg to h in g
|
|
private function inc(n : int) : int = n + 1
|
|
// Never used
|
|
private function dec(n : int) : int = n - 1
|
|
|
|
contract Remote =
|
|
entrypoint id(_) = 0
|
|
|
|
contract C =
|
|
payable stateful entrypoint
|
|
call_missing_con() : int = (ct_1111111111111111111111111111112JF6Dz72 : Remote).id(value = 1, 0)
|
|
|
|
namespace ShadowingConst =
|
|
let const = 1
|
|
|
|
function f() =
|
|
let const = 2
|
|
const
|
|
|
|
namespace UnusedConstNamespace =
|
|
// No warnings should be shown even though const is not used
|
|
let const = 1
|
|
|
|
contract UnusedConstContract =
|
|
// Only `c` should show a warning because it is never used in the contract
|
|
let a = 1
|
|
let b = 2
|
|
let c = 3
|
|
|
|
entrypoint f() =
|
|
// Both normal access and qualified access should prevent the unused const warning
|
|
a + UnusedConstContract.b
|