Skip to content

Commit

Permalink
Merge branch 'master' into alfie/6179-cargo-workspace-version
Browse files Browse the repository at this point in the history
  • Loading branch information
sdankel authored Sep 17, 2024
2 parents 087fb7d + a073a95 commit 4957517
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1631,8 +1631,7 @@ impl TypeCheckAnalysis for ty::ImplSelfOrTrait {
ctx.push_nodes_for_impl_trait(self);

// Now lets analyze each impl trait item.
for (i, item) in impl_trait.items.iter().enumerate() {
let _node = ctx.items_node_stack[i];
for item in impl_trait.items.iter() {
item.type_check_analyze(handler, ctx)?;
}

Expand Down
9 changes: 7 additions & 2 deletions sway-core/src/transform/to_parsed_lang/convert_parse_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4943,8 +4943,13 @@ pub fn cfg_eval(
}
},
_ => {
// Already checked with `AttributeKind::expected_args_*`
unreachable!("cfg attribute should only have the `target` or the `program_type` argument");
return Err(handler.emit_err(
ConvertParseTreeError::InvalidCfgArg {
span: arg.span(),
value: arg.name.as_str().to_string(),
}
.into(),
));
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions sway-error/src/convert_parse_tree_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ pub enum ConvertParseTreeError {
ExpectedCfgProgramTypeArgValue { span: Span },
#[error("Expected \"true\" or \"false\" for experimental_new_encoding")]
ExpectedExperimentalNewEncodingArgValue { span: Span },
#[error("Unexpected attribute value: \"{value}\" for attribute: \"cfg\"")]
InvalidCfgArg { span: Span, value: String },
}

impl Spanned for ConvertParseTreeError {
Expand Down Expand Up @@ -182,6 +184,7 @@ impl Spanned for ConvertParseTreeError {
ConvertParseTreeError::InvalidCfgProgramTypeArgValue { span, .. } => span.clone(),
ConvertParseTreeError::ExpectedCfgProgramTypeArgValue { span } => span.clone(),
ConvertParseTreeError::ExpectedExperimentalNewEncodingArgValue { span } => span.clone(),
ConvertParseTreeError::InvalidCfgArg { span, .. } => span.clone(),
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[[package]]
name = "invalid_cfg_arg"
source = "member"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[project]
name = "invalid_cfg_arg"
authors = ["Fuel Labs <[email protected]>"]
entry = "main.sw"
license = "Apache-2.0"
implicit-std = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
predicate;
#[cfg(c)] a
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
category = "fail"

# check: $()#[cfg(c)] a
# nextln: $()Unexpected attribute value: "c" for attribute: "cfg" expected value "target" or "program_type" or "experimental_new_encoding"

# check: $()#[cfg(c)] a
# nextln: $()Expected an item.

# check: $()#[cfg(c)] a
# nextln: $()Unexpected attribute value: "c" for attribute: "cfg"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[[package]]
name = "core"
source = "path+from-root-F62FA9D54ABC8F01"

[[package]]
name = "mismatch_closing_delimiters"
source = "member"
dependencies = ["core"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
authors = ["Fuel Labs <[email protected]>"]
license = "Apache-2.0"
name = "mismatch_closing_delimiters"
entry = "main.sw"
implicit-std = false

[dependencies]
core = { path = "../../../../../../sway-lib-core" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
script;

struct Struct{x:u}
impl Struct{
fn w()->f{{(()}}
trait Supertrait{}
impl Supertrait for Struct{)
}

fn s<A>(b:B) where A:t{}fn n(){}

fn main() -> u64 {
0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
category = "fail"

# check: $()fn w()->f{{(()}}
# nextln: $()mismatched delimiters

0 comments on commit 4957517

Please sign in to comment.