alloy-rs / core

High-performance, well-tested & documented core libraries for Ethereum, in Rust
https://alloy.rs
Apache License 2.0
763 stars 137 forks source link

[Bug] Solidity `hex` and `unicode` prefixes cause an error #600

Closed makcandrov closed 5 months ago

makcandrov commented 5 months ago

Component

sol! macro

What version of Alloy are you on?

0.7.0

Operating System

None

Describe the bug

alloy_sol_types::sol! {
    contract Contract {
        function foo() external {
            string memory s = unicode"a";
        }
    }
}
error: prefix `unicode` is unknown
 --> src\main.rs:4:31
  |
4 |             string memory s = unicode"a";
  |                               ^^^^^^^ unknown prefix
  |
  = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here
  |
4 |             string memory s = unicode "a";
  |                                      +
DaniPopes commented 5 months ago

This is a known limitation, rust fails lexing the code before even passing it to the macro.

https://github.com/alloy-rs/core/tree/main/crates/syn-solidity#known-limitations