Skip to content

Commit 4c2fbf9

Browse files
authored
fix: don't panic on certain optional types (#224)
1 parent 3a895d4 commit 4c2fbf9

File tree

7 files changed

+63
-12
lines changed

7 files changed

+63
-12
lines changed

wdl-format/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## 0.2.1 - 10-16-2024
11+
12+
### Fixed
13+
14+
* Don't panic on certain optional types ([#224](https://github.com/stjude-rust-labs/wdl/pull/224))
15+
1016
## 0.2.0 - 10-16-2024
1117

1218
### Added

wdl-format/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wdl-format"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
description = "Formatting of WDL (Workflow Description Language) documents"
55
license.workspace = true
66
edition.workspace = true

wdl-format/src/v1/decl.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ pub fn format_map_type(element: &FormatElement, stream: &mut TokenStream<PreToke
3333

3434
/// Formats an [`ObjectType`](wdl_ast::v1::ObjectType).
3535
pub fn format_object_type(element: &FormatElement, stream: &mut TokenStream<PreToken>) {
36-
let mut children = element.children().expect("object type children");
37-
let object_keyword = children.next().expect("object type object keyword");
38-
assert!(object_keyword.element().kind() == SyntaxKind::ObjectTypeKeyword);
39-
(&object_keyword).write(stream);
40-
assert!(children.next().is_none());
36+
for child in element.children().expect("object type children") {
37+
(&child).write(stream);
38+
}
4139
}
4240

4341
/// Formats a [`PairType`](wdl_ast::v1::PairType).
@@ -52,10 +50,9 @@ pub fn format_pair_type(element: &FormatElement, stream: &mut TokenStream<PreTok
5250

5351
/// Formats a [`TypeRef`](wdl_ast::v1::TypeRef).
5452
pub fn format_type_ref(element: &FormatElement, stream: &mut TokenStream<PreToken>) {
55-
let mut children = element.children().expect("type ref children");
56-
let t = children.next().expect("type ref type");
57-
(&t).write(stream);
58-
assert!(children.next().is_none());
53+
for child in element.children().expect("type ref children") {
54+
(&child).write(stream);
55+
}
5956
}
6057

6158
/// Formats an [`UnboundDecl`](wdl_ast::v1::UnboundDecl).
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version 1.1
2+
3+
struct SpliceJunctionMotifs {
4+
Int noncanonical_motifs
5+
Int GT_AG_and_CT_AC_motif
6+
}
7+
8+
workflow foo {
9+
input {
10+
SpliceJunctionMotifs? foo
11+
}
12+
13+
SpliceJunctionMotifs declared = SpliceJunctionMotifs {
14+
noncanonical_motifs: 1,
15+
GT_AG_and_CT_AC_motif: 2,
16+
}
17+
SpliceJunctionMotifs? optional = None
18+
Object? deprecated = None
19+
20+
output {
21+
SpliceJunctionMotifs? bar = declared
22+
}
23+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version 1.1
2+
struct SpliceJunctionMotifs {
3+
Int noncanonical_motifs
4+
Int GT_AG_and_CT_AC_motif
5+
}
6+
workflow foo {
7+
SpliceJunctionMotifs declared = SpliceJunctionMotifs {
8+
noncanonical_motifs: 1,
9+
GT_AG_and_CT_AC_motif: 2
10+
}
11+
SpliceJunctionMotifs? optional = None
12+
Object? deprecated = None
13+
input {
14+
SpliceJunctionMotifs? foo
15+
}
16+
output {
17+
SpliceJunctionMotifs? bar = declared
18+
}
19+
}

wdl/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## 0.9.1 - 10-16-2024
11+
12+
### Fixed
13+
14+
* Fixed a bug in `wdl-format` that panicked on certain optional types ([#224](https://github.com/stjude-rust-labs/wdl/pull/224))
15+
1016
## 0.9.0 - 10-16-2024
1117

1218
### Added

wdl/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wdl"
3-
version = "0.9.0"
3+
version = "0.9.1"
44
authors = ["Clay McLeod <clay.l.mcleod@gmail.com>"]
55
rust-version.workspace = true
66
license.workspace = true
@@ -17,7 +17,7 @@ wdl-ast = { path = "../wdl-ast", version = "0.8.0", optional = true }
1717
wdl-lint = { path = "../wdl-lint", version = "0.7.0", optional = true }
1818
wdl-analysis = { path = "../wdl-analysis", version = "0.4.0", optional = true }
1919
wdl-lsp = { path = "../wdl-lsp", version = "0.4.0", optional = true }
20-
wdl-format = { path = "../wdl-format", version = "0.2.0", optional = true }
20+
wdl-format = { path = "../wdl-format", version = "0.2.1", optional = true }
2121
tracing-subscriber = { workspace = true, optional = true }
2222
clap = { workspace = true, optional = true }
2323
anyhow = { workspace = true, optional = true }

0 commit comments

Comments
 (0)