Skip to content

Commit

Permalink
[compiler] Typedefs for Array.prototype.flatMap
Browse files Browse the repository at this point in the history
ghstack-source-id: af4c7ac2fd26f6ff332a1af0055c80b70838efee
Pull Request resolved: #30794
  • Loading branch information
josephsavona committed Aug 23, 2024
1 parent 039c5c0 commit 37c6ea8
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,23 @@ addObject(BUILTIN_SHAPES, BuiltInArrayId, [
mutableOnlyIfOperandsAreMutable: true,
}),
],
[
'flatMap',
addFunction(BUILTIN_SHAPES, [], {
positionalParams: [],
restParam: Effect.ConditionallyMutate,
returnType: {kind: 'Object', shapeId: BuiltInArrayId},
/*
* callee is ConditionallyMutate because items of the array
* flow into the lambda and may be mutated there, even though
* the array object itself is not modified
*/
calleeEffect: Effect.ConditionallyMutate,
returnValueKind: ValueKind.Mutable,
noAlias: true,
mutableOnlyIfOperandsAreMutable: true,
}),
],
[
'filter',
addFunction(BUILTIN_SHAPES, [], {
Expand Down Expand Up @@ -534,6 +551,17 @@ addObject(BUILTIN_SHAPES, BuiltInMixedReadonlyId, [
noAlias: true,
}),
],
[
'flatMap',
addFunction(BUILTIN_SHAPES, [], {
positionalParams: [],
restParam: Effect.Read,
returnType: {kind: 'Object', shapeId: BuiltInArrayId},
calleeEffect: Effect.ConditionallyMutate,
returnValueKind: ValueKind.Mutable,
noAlias: true,
}),
],
[
'filter',
addFunction(BUILTIN_SHAPES, [], {
Expand Down

0 comments on commit 37c6ea8

Please sign in to comment.