-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: relax type hints on flatten function
The documented type signature of the flatten function is <list<dyn>> -> <list<dyn>>, but the implementation was <list<typeV>> -> <list<typeV>>. This has an impact on uses of flatten where the input is a nested set of lists, the exact intended use-case. In this situation, the type checker is told that the returned value is a list of lists..., resulting in rejection of valid programs. There is a work-around that can be used, but instead, just make the implementation match the documentation and intention.
- Loading branch information
Showing
2 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
mito -use collections -data state.json src.cel | ||
! stderr . | ||
cmp stdout want.txt | ||
|
||
-- state.json -- | ||
{ | ||
"aye": { | ||
"value": 1 | ||
}, | ||
"bee": { | ||
"value": "two" | ||
}, | ||
"one": [ | ||
{ | ||
"value": 1 | ||
}, | ||
{ | ||
"value": "two" | ||
} | ||
], | ||
"two": [ | ||
{ | ||
"value": 3 | ||
}, | ||
{ | ||
"value": "four" | ||
} | ||
] | ||
} | ||
|
||
-- src.cel -- | ||
[ | ||
"one", | ||
"two", | ||
].map(k, state[k].map(e, { | ||
k: e, | ||
})).flatten().map(d, d.with({ | ||
"aye": state.aye, | ||
"bee": state.bee, | ||
})) | ||
-- want.txt -- | ||
[ | ||
{ | ||
"aye": { | ||
"value": 1 | ||
}, | ||
"bee": { | ||
"value": "two" | ||
}, | ||
"one": { | ||
"value": 1 | ||
} | ||
}, | ||
{ | ||
"aye": { | ||
"value": 1 | ||
}, | ||
"bee": { | ||
"value": "two" | ||
}, | ||
"one": { | ||
"value": "two" | ||
} | ||
}, | ||
{ | ||
"aye": { | ||
"value": 1 | ||
}, | ||
"bee": { | ||
"value": "two" | ||
}, | ||
"two": { | ||
"value": 3 | ||
} | ||
}, | ||
{ | ||
"aye": { | ||
"value": 1 | ||
}, | ||
"bee": { | ||
"value": "two" | ||
}, | ||
"two": { | ||
"value": "four" | ||
} | ||
} | ||
] |