Skip to content

Commit 9ba9600

Browse files
committed
Properly parse the target of a record update.
Fixes #796
1 parent a75df2f commit 9ba9600

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

spec/examples/record_update

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,22 @@ component Main {
106106
""
107107
}
108108
}
109+
-------------------------------------------------------------------------------
110+
type A {
111+
b: B
112+
}
113+
114+
type B {
115+
str: String
116+
}
117+
118+
component Main {
119+
fun render {
120+
let data = {b: {str: "text" }}
121+
122+
// let's create a copy updating only the "text"
123+
let dataUpdated = { data | b: { data.b | str: "text2" } }
124+
125+
"ok"
126+
}
127+
}

src/parsers/record_update.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Mint
66
next unless char! '{'
77
whitespace
88

9-
value = variable || self.expression
9+
value = self.expression
1010
whitespace
1111

1212
next unless value

0 commit comments

Comments
 (0)