Skip to content

Conversation

@jeffcharles
Copy link
Contributor

Adds an eprintln macro to the prelude. If someone has an import like use shopify_function::prelude::*; and they use eprintln, they'll get a compiler error that looks like:

error[E0659]: `eprintln` is ambiguous
  --> example_with_targets/src/main.rs:50:5
   |
50 |     eprintln!("hello");
   |     ^^^^^^^^ ambiguous name
   |
   = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
   = note: `eprintln` could refer to a macro from prelude
note: `eprintln` could also refer to the macro imported here
  --> example_with_targets/src/main.rs:3:5
   |
 3 | use shopify_function::prelude::*;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: consider adding an explicit import of `eprintln` to disambiguate
   = help: or use `crate::eprintln` to refer to this macro unambiguously

warning: use of deprecated macro `eprintln`: Use log! instead
  --> example_with_targets/src/main.rs:50:5
   |
50 |     eprintln!("hello");
   |     ^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default

For more information about this error, try `rustc --explain E0659`.
warning: `example_with_targets` (bin "example_with_targets") generated 1 warning
error: could not compile `example_with_targets` (bin "example_with_targets") due to 1 previous error; 1 warning emitted

The reason for this change is we want to users of the crate to not use eprintln! and a compiler warning or error will do that.

I checked with @davejcameron and he said that is an acceptable error message given that Claude Sonnet 4.5 is able to deduce that the correct fix is to replace the call to eprintln! with log! due to the deprecation warning message. Ideally, I'd like this to only trigger a compiler warning with just the deprecation message given the error message is difficult for someone less familiar with Rust to understand, but I am not sure how to do that.

@jeffcharles jeffcharles requested a review from adampetro October 29, 2025 19:37
@jeffcharles jeffcharles merged commit 5c058b0 into main Oct 29, 2025
4 checks passed
@jeffcharles jeffcharles deleted the jc.shadow-eprintln branch October 29, 2025 20:57
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.

2 participants