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

debug_print(ln) fails for temporary values #1261

Closed
xgreenx opened this issue May 18, 2022 · 5 comments
Closed

debug_print(ln) fails for temporary values #1261

xgreenx opened this issue May 18, 2022 · 5 comments
Assignees

Comments

@xgreenx
Copy link
Collaborator

xgreenx commented May 18, 2022

After #1258, the debug_print(ln)! macro fails for temporary variables if the "ink-debug" feature is disabled.

image

@athei
Copy link
Contributor

athei commented May 24, 2022

I can't reproduce. Building this example with:

cargo +nightly contract build --release

This should disable this feature. The CI would have also caught this error. Can you give more instructions?

@xgreenx
Copy link
Collaborator Author

xgreenx commented May 24, 2022

You need to remove "ink-debug" from Cargo.toml=)

@athei
Copy link
Contributor

athei commented May 24, 2022

Ahh okay it shouldn't be there. I think it is a left over. Can reproduce it now.

@SkymanOne SkymanOne self-assigned this Oct 12, 2022
@SkymanOne
Copy link
Contributor

Can't reproduce the issue with the latest ink! 4.0 release. ink-debug seems not to be in Cargo.toml

@cmichi
Copy link
Collaborator

cmichi commented Oct 13, 2022

Looked into it. So the story with ink-debug is that if you execute cargo contract build the default behavior is that cargo-contract builds the contract with --features=ink/ink-debug. That's the reason why the Cargo.toml of the contract-transfer example doesn't need to contain any ink-debug feature anymore.

If you build the contract with cargo contract build --release the debug_print and debug_println macros won't output whatever was passed to them:

if #[cfg(any(feature = "ink-debug", feature = "std"))] {} else {
    #[macro_export]
    /// Debug messages disabled. Enable the `ink-debug` feature for contract debugging.
    macro_rules! debug_print {
        ($($arg:tt)*) => ();
    }

    #[macro_export]
    /// Debug messages disabled. Enable the `ink-debug` feature for contract debugging.
    macro_rules! debug_println {
        () => ();
        ($($arg:tt)*) => ();
    }
}

(from https://github.com/paritytech/ink/blob/master/crates/env/src/lib.rs).

Hence the bug can no longer occur, as what was a temporary variable in Green's original issue report is swallowed by the macros in case the feature is not enabled.

@cmichi cmichi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 13, 2022
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

No branches or pull requests

4 participants