Skip to content

Commit

Permalink
fix(check): Propagate metadata through parens
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed May 17, 2019
1 parent ca8528c commit bd767c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion check/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl ArcMetadata for MaybeMetadata {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
enum MaybeMetadata {
Empty,
Data(Arc<Metadata>),
Expand Down Expand Up @@ -371,6 +371,7 @@ pub fn metadata(
Expr::MacroExpansion {
ref replacement, ..
} => self.metadata_expr(replacement),
Expr::Tuple { ref elems, .. } if elems.len() == 1 => self.metadata_expr(&elems[0]),
_ => {
ast::walk_expr(self, expr);
Default::default()
Expand Down
25 changes: 25 additions & 0 deletions check/tests/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,31 @@ type Test = Int
);
}

#[test]
fn propagate_metadata_parens() {
let _ = env_logger::try_init();

let text = r#"
/// The identity function
let id x = x
id
"#;
let (mut expr, result) = support::typecheck_expr(text);

assert!(result.is_ok(), "{}", result.unwrap_err());

let metadata = metadata(&MockEnv, &mut expr);
assert_eq!(
metadata,
Metadata {
definition: Some(intern("id:32")),
comment: Some(line_comment("The identity function")),
args: vec![Argument::explicit(intern("x:35"))],
..Metadata::default()
}
);
}

#[test]
fn propagate_metadata_record_field_comment() {
let _ = env_logger::try_init();
Expand Down

0 comments on commit bd767c0

Please sign in to comment.