Skip to content

Commit ddbbb7a

Browse files
committed
Parse array spreads only inside arrays
1 parent b30e9d8 commit ddbbb7a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/ast.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ pub enum PairOrSpread<'input> {
3030
Spread(&'input str),
3131
}
3232

33+
/// Represents a chained key like "foo.bar.baz"
34+
#[derive(Debug, Clone)]
35+
pub struct ChainedKey<'input> {
36+
/// The segments of the key path
37+
pub segments: Vec<&'input str>,
38+
}
39+
3340
/// An entry can be of various types as defined in the spec
3441
#[derive(Debug, Clone)]
3542
pub enum Entry<'input> {
@@ -44,18 +51,18 @@ pub enum Entry<'input> {
4451
/// Nested object
4552
Object(Object<'input>),
4653
/// Array of entries
47-
Array(Vec<Entry<'input>>),
54+
Array(Vec<EntryOrSpread<'input>>),
4855
/// Null value
4956
Null,
5057
/// Reference to an input variable
5158
Input(&'input str),
52-
/// Array spread operation
53-
Spread(&'input str),
5459
}
5560

56-
/// Represents a chained key like "foo.bar.baz"
61+
/// Either a key or an array spread operation
5762
#[derive(Debug, Clone)]
58-
pub struct ChainedKey<'input> {
59-
/// The segments of the key path
60-
pub segments: Vec<&'input str>,
63+
pub enum EntryOrSpread<'input> {
64+
/// An entry can be of various types as defined in the spec
65+
Entry(Entry<'input>),
66+
/// Array spread operation
67+
Spread(&'input str),
6168
}

0 commit comments

Comments
 (0)