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

chore: update solang-parser #4661

Merged
merged 16 commits into from
Apr 18, 2023
665 changes: 319 additions & 346 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,14 @@ ethers-middleware = { version = "2", default-features = false }
ethers-etherscan = { version = "2", default-features = false }
ethers-solc = { version = "2", default-features = false }

# # Patch ethers-rs with a local checkout then run `cargo update -p ethers`
# [patch."https://github.com/gakonst/ethers-rs"]
# ethers = { path = "../ethers-rs" }
#[patch.crates-io]
# ethers = { path = "../ethers-rs/ethers" }
# ethers-addressbook = { path = "../ethers-rs/ethers-addressbook" }
# ethers-core = { path = "../ethers-rs/ethers-core" }
# ethers-contract = { path = "../ethers-rs/ethers-contract" }
# ethers-core = { path = "../ethers-rs/ethers-core" }
# ethers-etherscan = { path = "../ethers-rs/ethers-etherscan" }
# ethers-middleware = { path = "../ethers-rs/ethers-middleware" }
# ethers-providers = { path = "../ethers-rs/ethers-providers" }
# ethers-signers = { path = "../ethers-rs/ethers-signers" }
# ethers-etherscan = { path = "../ethers-rs/ethers-etherscan" }
# ethers-solc = { path = "../ethers-rs/ethers-solc" }

# [patch.crates-io]
# revm = { path = "../revm/crates/revm" }
2 changes: 1 addition & 1 deletion chisel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ reqwest = { version = "0.11", default-features = false, features = ["rustls"] }
# misc
clap = { version = "4.2", features = ["derive", "env", "wrap_help"] }
rustyline = "11.0"
solang-parser = "=0.2.3"
solang-parser = "=0.2.4"
yansi = "0.5"
strum = { version = "0.24.1", features = ["derive"] }
serde = "1.0.159"
Expand Down
2 changes: 1 addition & 1 deletion chisel/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ impl Type {
pt::Expression::New(_, inner) | // new <inner>
pt::Expression::UnaryPlus(_, inner) | // +<inner>
// ops
pt::Expression::Complement(_, inner) | // ~<inner>
pt::Expression::BitwiseNot(_, inner) | // ~<inner>
pt::Expression::ArraySlice(_, inner, _, _) | // <inner>[*start*:*end*]
// assign ops
pt::Expression::PreDecrement(_, inner) | // --<inner>
Expand Down
15 changes: 1 addition & 14 deletions chisel/src/solidity_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl SolidityHelper {

/// Highlights a solidity source string
pub fn highlight(input: &str) -> Cow<str> {
if !Paint::is_enabled() || Self::skip_input(input) {
if !Paint::is_enabled() {
return Cow::Borrowed(input)
}

Expand Down Expand Up @@ -150,11 +150,6 @@ impl SolidityHelper {

/// Validate that a source snippet is closed (i.e., all braces and parenthesis are matched).
fn validate_closed(input: &str) -> ValidationResult {
if Self::skip_input(input) {
let msg = Paint::red("\nInput must not start with `.<number>`");
return ValidationResult::Invalid(Some(msg.to_string()))
}

let mut bracket_depth = 0usize;
let mut paren_depth = 0usize;
let mut brace_depth = 0usize;
Expand Down Expand Up @@ -218,14 +213,6 @@ impl SolidityHelper {
Self::paint_unchecked(string, style, &mut out);
out
}

/// Whether to skip parsing this input due to known errors or panics
#[inline]
fn skip_input(input: &str) -> bool {
// input.startsWith(/\.[0-9]/)
let mut chars = input.chars();
chars.next() == Some('.') && chars.next().map(|c| c.is_ascii_digit()).unwrap_or_default()
}
}

impl Highlighter for SolidityHelper {
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ui = { path = "../ui" }

# eth
ethers = { workspace = true, features = ["rustls"] }
solang-parser = "=0.2.3"
solang-parser = "=0.2.4"

# cli
clap = { version = "4.2", features = ["derive", "env", "unicode", "wrap_help"] }
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cmd/forge/geiger/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl Visitor for CheatcodeVisitor {
Expression::Not(_, expr) => {
expr.visit(self)?;
}
Expression::Complement(_, expr) => {
Expression::BitwiseNot(_, expr) => {
expr.visit(self)?;
}
Expression::Delete(_, expr) => {
Expand Down
2 changes: 1 addition & 1 deletion doc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tokio = { version = "1.27", features = ["macros", "rt-multi-thread"] }
futures-util = "0.3"

# misc
solang-parser = "=0.2.3"
solang-parser = "=0.2.4"
eyre = "0.6"
thiserror = "1.0.40"
rayon = "1.7"
Expand Down
2 changes: 1 addition & 1 deletion doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ pub use parser::{
pub use preprocessor::*;

/// Traits for formatting items into doc output.
pub use writer::{AsDoc, AsDocResult, AsString, BufWriter, Markdown};
pub use writer::{AsDoc, AsDocResult, BufWriter, Markdown};
4 changes: 2 additions & 2 deletions doc/src/writer/as_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
document::{read_context, DocumentContent},
parser::ParseSource,
writer::BufWriter,
AsString, CommentTag, Comments, CommentsRef, Document, Markdown, PreprocessorOutput,
CommentTag, Comments, CommentsRef, Document, Markdown, PreprocessorOutput,
CONTRACT_INHERITANCE_ID, GIT_SOURCE_ID, INHERITDOC_ID,
};
use forge_fmt::solang_ext::SafeUnwrap;
Expand Down Expand Up @@ -91,7 +91,7 @@ impl AsDoc for Document {
"({})",
func.params
.iter()
.map(|p| p.1.as_ref().map(|p| p.ty.as_string()).unwrap_or_default())
.map(|p| p.1.as_ref().map(|p| p.ty.to_string()).unwrap_or_default())
.join(", ")
));
}
Expand Down
242 changes: 0 additions & 242 deletions doc/src/writer/as_string.rs

This file was deleted.

4 changes: 2 additions & 2 deletions doc/src/writer/buf_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use once_cell::sync::Lazy;
use solang_parser::pt::Parameter;
use std::fmt::{self, Display, Write};

use crate::{AsDoc, AsString, CommentTag, Comments, Markdown};
use crate::{AsDoc, CommentTag, Comments, Markdown};

/// Solidity language name.
const SOLIDITY: &str = "solidity";
Expand Down Expand Up @@ -152,7 +152,7 @@ impl BufWriter {

let row = [
Markdown::Code(&param_name.unwrap_or_else(|| "<none>".to_owned())).as_doc()?,
Markdown::Code(&param.ty.as_string()).as_doc()?,
Markdown::Code(&param.ty.to_string()).as_doc()?,
comment.unwrap_or_default().replace('\n', " "),
];
self.write_piped(&row.join("|"))?;
Expand Down
2 changes: 0 additions & 2 deletions doc/src/writer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//! The module for writing and formatting various parse tree items.

mod as_doc;
mod as_string;
mod buf_writer;
mod markdown;

pub use as_doc::{AsDoc, AsDocResult};
pub use as_string::AsString;
pub use buf_writer::BufWriter;
pub use markdown::Markdown;
Loading