Skip to content

Commit 0d4724b

Browse files
authored
chore: bump solar, warn on invalid natspec (#12540)
1 parent 1504cb0 commit 0d4724b

File tree

4 files changed

+68
-23
lines changed

4 files changed

+68
-23
lines changed

Cargo.lock

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "7e59936" }
451451
# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "b4299fc" }
452452

453453
# solar
454-
solar = { package = "solar-compiler", git = "https://github.com/paradigmxyz/solar.git", rev = "0bea5f0" }
455-
solar-interface = { package = "solar-interface", git = "https://github.com/paradigmxyz/solar.git", rev = "0bea5f0" }
456-
solar-ast = { package = "solar-ast", git = "https://github.com/paradigmxyz/solar.git", rev = "0bea5f0" }
457-
solar-sema = { package = "solar-sema", git = "https://github.com/paradigmxyz/solar.git", rev = "0bea5f0" }
454+
solar = { package = "solar-compiler", git = "https://github.com/paradigmxyz/solar.git", rev = "1f28069" }
455+
solar-interface = { package = "solar-interface", git = "https://github.com/paradigmxyz/solar.git", rev = "1f28069" }
456+
solar-ast = { package = "solar-ast", git = "https://github.com/paradigmxyz/solar.git", rev = "1f28069" }
457+
solar-sema = { package = "solar-sema", git = "https://github.com/paradigmxyz/solar.git", rev = "1f28069" }

crates/cli/src/opts/build/utils.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ use foundry_compilers::{
55
multi::{MultiCompilerLanguage, MultiCompilerParser},
66
solc::{SOLC_EXTENSIONS, SolcLanguage, SolcVersionedInput},
77
};
8-
use foundry_config::{Config, semver::Version};
8+
use foundry_config::Config;
99
use rayon::prelude::*;
10-
use solar::{interface::MIN_SOLIDITY_VERSION as MSV, sema::ParsingContext};
10+
use solar::{interface::MIN_SOLIDITY_VERSION, sema::ParsingContext};
1111
use std::{
1212
collections::{HashSet, VecDeque},
1313
path::{Path, PathBuf},
1414
};
1515

16-
const MIN_SUPPORTED_VERSION: Version = Version::new(MSV.0, MSV.1, MSV.2);
17-
1816
/// Configures a [`ParsingContext`] from [`Config`].
1917
///
2018
/// - Configures include paths, remappings
@@ -62,10 +60,10 @@ pub fn configure_pcx(
6260
.1
6361
.into_iter()
6462
// Filter unsupported versions
65-
.filter(|(v, _, _)| v >= &MIN_SUPPORTED_VERSION)
63+
.filter(|(v, _, _)| v >= &MIN_SOLIDITY_VERSION)
6664
// Always pick the latest version
6765
.max_by(|(v1, _, _), (v2, _, _)| v1.cmp(v2))
68-
.map_or((MIN_SUPPORTED_VERSION, Sources::default()), |(v, s, _)| (v, s));
66+
.map_or((MIN_SOLIDITY_VERSION, Sources::default()), |(v, s, _)| (v, s));
6967

7068
if sources.is_empty() {
7169
sh_warn!("no files found. Solar doesn't support Solidity versions prior to 0.8.0")?;
@@ -132,12 +130,12 @@ pub fn get_solar_sources_from_compile_output(
132130

133131
// Read all sources and find the latest version.
134132
let (version, sources) = {
135-
let (mut max_version, mut sources) = (MIN_SUPPORTED_VERSION, Sources::new());
133+
let (mut max_version, mut sources) = (MIN_SOLIDITY_VERSION, Sources::new());
136134
for (id, _) in output.artifact_ids() {
137135
if let Ok(path) = dunce::canonicalize(&id.source)
138136
&& source_paths.remove(&path)
139137
{
140-
if id.version < MIN_SUPPORTED_VERSION {
138+
if id.version < MIN_SOLIDITY_VERSION {
141139
continue;
142140
} else if max_version < id.version {
143141
max_version = id.version;

crates/forge/tests/cli/build.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,49 @@ with remappings:
412412
413413
"#]]);
414414
});
415+
416+
// <https://github.com/foundry-rs/foundry/issues/12458>
417+
// <https://github.com/foundry-rs/foundry/issues/12496>
418+
forgetest!(build_with_invalid_natspec, |prj, cmd| {
419+
prj.add_source(
420+
"ContractWithInvalidNatspec.sol",
421+
r#"
422+
contract ContractA {
423+
/// @deprecated quoteExactOutputSingle and exactOutput. Use QuoterV2 instead.
424+
}
425+
426+
/// Some editors highlight `@note` or `@todo`
427+
/// @note foo bar
428+
429+
/// @title ContractB
430+
contract ContractB {
431+
/**
432+
some example code in a comment:
433+
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
434+
*/
435+
}
436+
"#,
437+
);
438+
439+
cmd.args(["build", "src/ContractWithInvalidNatspec.sol"]).assert_success().stderr_eq(str![[
440+
r#"
441+
warning: invalid natspec tag '@deprecated', custom tags must use format '@custom:name'
442+
[FILE]:5:5
443+
|
444+
5 | /// @deprecated quoteExactOutputSingle and exactOutput. Use QuoterV2 instead.
445+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
446+
|
447+
...
448+
449+
warning: invalid natspec tag '@note', custom tags must use format '@custom:name'
450+
[FILE]:9:1
451+
|
452+
9 | /// @note foo bar
453+
| ^^^^^^^^^^^^^^^^^
454+
|
455+
...
456+
457+
458+
"#
459+
]]);
460+
});

0 commit comments

Comments
 (0)