Skip to content

Commit

Permalink
Fix 'literal too large error' for hex literals
Browse files Browse the repository at this point in the history
  • Loading branch information
g-r-a-n-t committed Feb 12, 2021
1 parent 4db24c7 commit 1e883ad
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/shorthand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::yul;
macro_rules! literal {
{[$e:expr]} => {$e};
{($e:expr)} => {yul::Literal { literal: $e.to_string(), yultype: None }};
{$l:literal} => {yul::Literal { literal: stringify!($l).to_string(), yultype: None }};
{$l:tt} => {yul::Literal { literal: stringify!($l).to_string(), yultype: None }};
}

/// Creates a Yul literal expression.
Expand Down Expand Up @@ -363,6 +363,15 @@ macro_rules! for_loop {
mod tests {
use crate::yul;

#[test]
fn literal_hex() {
assert_eq!(
literal! { 0x4200000000000000000000000000000000000000000000000000000000420026 }
.to_string(),
"0x4200000000000000000000000000000000000000000000000000000000420026"
)
}

#[test]
fn literal_string() {
assert_eq!(literal! {"foo"}.to_string(), r#""foo""#)
Expand Down

0 comments on commit 1e883ad

Please sign in to comment.