Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions crates/artifacts/solc/src/sourcemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,20 +556,23 @@ enum State {

impl State {
fn advance(&mut self, pos: usize) -> Result<(), SyntaxError> {
match self {
Self::Offset => *self = Self::Length,
Self::Length => *self = Self::Index,
Self::Index => *self = Self::Jmp,
Self::Jmp => *self = Self::Modifier,
*self = match self {
Self::Offset => Self::Length,
Self::Length => Self::Index,
Self::Index => Self::Jmp,
Self::Jmp => Self::Modifier,
Self::Modifier => return Err(SyntaxError::new(pos, "unexpected colon")),
}
};
Ok(())
}
}

/// Parses a source map
/// Parses a source map.
pub fn parse(input: &str) -> Result<SourceMap, SyntaxError> {
Parser::new(input).collect()
Parser::new(input).collect::<Result<SourceMap, SyntaxError>>().map(|mut v| {
v.shrink_to_fit();
v
})
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion crates/compilers/src/compilers/solc/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ fn version_from_output(output: Output) -> Result<Version> {
let version = stdout
.lines()
.filter(|l| !l.trim().is_empty())
.last()
.next_back()
.ok_or_else(|| SolcError::msg("Version not found in Solc output"))?;
// NOTE: semver doesn't like `+` in g++ in build metadata which is invalid semver
Ok(Version::from_str(&version.trim_start_matches("Version: ").replace(".g++", ".gcc"))?)
Expand Down
Loading