Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress unused variable warning for debug_print macros #1258

Merged
merged 3 commits into from May 18, 2022

Conversation

athei
Copy link
Contributor

@athei athei commented May 17, 2022

If a variable is only used in the debug_print(ln)? macro then a unused variable warning is emitted in case the ink-debug feature isn't used. This fixes this problem by always using the arguments without evaluating them: Capture them by reference in a closure that is never executed.

@agryaznov had this problem in his mother contract.

@athei athei changed the title Suppress unused variable error for debug_print macros Suppress unused variable warning for debug_print macros May 17, 2022
agryaznov added a commit that referenced this pull request May 17, 2022
@athei
Copy link
Contributor Author

athei commented May 17, 2022

Any idea why the waterfall is failing? The error seems cryptic to me.

@paritytech-cicd-pr
Copy link

🦑 📈 ink! Example Contracts ‒ Changes Report 📉 🦑

⚠️ The ink! master is ahead of your branch, this might skew the comparison data below.

These are the results when building the examples/* contracts from this branch with cargo-contract 1.3.0-a2fe989 and comparing them to ink! master:

Δ Optimized Size Δ Used Gas Total Optimized Size Total Used Gas
accumulator +1.04 K 1.04 K
adder +2.13 K 2.13 K
contract-introspection +2.37 K 2.37 K
contract-terminate +0.94 K 0.94 K 275_000
contract-transfer +8.13 K 8.13 K 75_000
data-structures +1.73 K 1.73 K
delegate-calls +2.96 K 2.96 K 76_276
delegator +6.38 K 6.38 K 232_281
dns +8.84 K 8.84 K 225_000
erc1155 +17.34 K 17.34 K 450_000
erc20 +8.49 K 8.49 K 225_000
erc721 +11.81 K 11.81 K 600_000
flipper +1.31 K 1.31 K 75_000
forward-calls +2.88 K 2.88 K 151_427
incrementer +1.21 K 1.21 K
multisig +25.15 K 25.15 K 470_178
rand-extension +3.92 K 3.92 K 75_000
seal-code-hash +1.58 K 1.58 K
set-code-hash +1.57 K 1.57 K 150_000
subber +2.15 K 2.15 K
trait-erc20 +8.77 K 8.77 K 225_000
trait-flipper +1.00 K 1.00 K 75_000
trait-incrementer +1.19 K 1.19 K 150_000
updated-incrementer +9.62 K 9.62 K
upgradeable-flipper +1.55 K 1.55 K

Link to the run | Last update: Wed May 18 08:41:17 CEST 2022

@codecov-commenter
Copy link

Codecov Report

Merging #1258 (2f15aeb) into master (961c7ef) will decrease coverage by 16.82%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           master    #1258       +/-   ##
===========================================
- Coverage   79.12%   62.30%   -16.83%     
===========================================
  Files         227      227               
  Lines        8638     8638               
===========================================
- Hits         6835     5382     -1453     
- Misses       1803     3256     +1453     
Impacted Files Coverage Δ
crates/lang/codegen/src/traits.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/ir/src/ir/contract.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/env.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/mod.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/enforced_error.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/blake2b.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/storage.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/arg_list.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/contract.rs 0.00% <0.00%> (-100.00%) ⬇️
crates/lang/codegen/src/generator/selector.rs 0.00% <0.00%> (-100.00%) ⬇️
... and 40 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 961c7ef...2f15aeb. Read the comment docs.

@cmichi
Copy link
Collaborator

cmichi commented May 18, 2022

Any idea why the waterfall is failing? The error seems cryptic to me.

Just reran it, this worked, I think it was a temporary network failure.

@cmichi cmichi merged commit b6dd935 into master May 18, 2022
@cmichi cmichi deleted the at/unused-var-error branch May 18, 2022 06:45
@athei
Copy link
Contributor Author

athei commented May 18, 2022

The size report of the waterfall seems buggy. It reports its whole size as increase.

agryaznov added a commit that referenced this pull request May 18, 2022
agryaznov added a commit that referenced this pull request May 18, 2022
* first iteration of the BIOC

* clippy fixes

* suppress unused var warning for debug fn

* suppress unused var warning 2nd try

* + tests

* Apply suggestions from code review

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* renamed to `mother`; added storage

* refactor

* added a Mapping into contract storage

* default constructor

* reverted fix

* fix

* Apply suggestions from code review

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* make it build (but not instantiate)

* fmt

* Update examples/mother/lib.rs

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* Apply suggestions from code review

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* reverted constructor delegation to satisfy CI (until #1259 fixed)

* added required input types

* custom event added

* CI clippy satisfaction

* trick to satisfy the CI until #1258 is fixed

* Revert "trick to satisfy the CI until #1258 is fixed"

This reverts commit 3491cfd.

Co-authored-by: Alexander Theißen <alex.theissen@me.com>
@xgreenx
Copy link
Collaborator

xgreenx commented May 18, 2022

Now if I remove "ink-debug" from contract-transfer example it emits an error=)
image

@athei
Copy link
Contributor Author

athei commented May 18, 2022

Thanks for reporting. I thought this case would have been covered by CI. Apparently not. Can you create an issue from that?

cmichi added a commit that referenced this pull request May 25, 2022
cmichi added a commit that referenced this pull request May 25, 2022
…" (#1276)

* Revert "Suppress unused variable warning for debug_print macros (#1258)"

This reverts commit b6dd935.

* Add workaround for unused bug
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.

None yet

6 participants