Skip to content

Commit

Permalink
Don't serialize empty 'digest' on IfExprs
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchalmers committed Oct 31, 2024
1 parent 10b01c0 commit 3cae080
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/wasm-lib/kcl/src/ast/types/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub struct IfExpression {
pub else_ifs: NodeList<ElseIf>,
pub final_else: BoxNode<IfBlock>,

#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub digest: Option<Digest>,
}

Expand All @@ -36,6 +38,8 @@ pub struct ElseIf {
pub cond: Expr,
pub then_val: BoxNode<IfBlock>,

#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub digest: Option<Digest>,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
snapshot_kind: text
---
{
"body": [
Expand All @@ -23,7 +24,6 @@ expression: actual
"type": "Literal",
"value": true
},
"digest": null,
"else_ifs": [],
"end": 74,
"final_else": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
snapshot_kind: text
---
{
"body": [
Expand All @@ -23,7 +24,6 @@ expression: actual
"type": "Literal",
"value": true
},
"digest": null,
"else_ifs": [
{
"cond": {
Expand All @@ -48,7 +48,6 @@ expression: actual
"type": "CallExpression",
"type": "CallExpression"
},
"digest": null,
"end": 90,
"start": 44,
"then_val": {
Expand Down
6 changes: 0 additions & 6 deletions src/wasm-lib/kcl/tests/if_else/ast.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ snapshot_kind: text
"type": "Literal",
"value": true
},
"digest": null,
"else_ifs": [
{
"cond": {
Expand All @@ -36,7 +35,6 @@ snapshot_kind: text
"type": "Literal",
"value": true
},
"digest": null,
"end": 88,
"start": 68,
"then_val": {
Expand Down Expand Up @@ -188,7 +186,6 @@ snapshot_kind: text
"type": "Literal",
"value": false
},
"digest": null,
"else_ifs": [
{
"cond": {
Expand All @@ -199,7 +196,6 @@ snapshot_kind: text
"type": "Literal",
"value": true
},
"digest": null,
"end": 202,
"start": 182,
"then_val": {
Expand Down Expand Up @@ -351,7 +347,6 @@ snapshot_kind: text
"type": "Literal",
"value": false
},
"digest": null,
"else_ifs": [
{
"cond": {
Expand All @@ -362,7 +357,6 @@ snapshot_kind: text
"type": "Literal",
"value": false
},
"digest": null,
"end": 322,
"start": 301,
"then_val": {
Expand Down

0 comments on commit 3cae080

Please sign in to comment.