Skip to content

Commit dcc4730

Browse files
committed
Add a special rule for the effect of Array.array
1 parent 8b6622b commit dcc4730

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/cps/syntax.sml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ struct
266266
| isDiscardable (PrimOp {primOp = F.ConstructExnOp, ...}) = true
267267
| isDiscardable (PrimOp {primOp = F.ConstructExnWithPayloadOp, ...}) =
268268
true
269+
| isDiscardable
270+
(PrimOp
271+
{ primOp = F.PrimCall (Primitives.Array_array _)
272+
, args = [IntConst (_, n), _]
273+
, ...
274+
}) = 0 <= n andalso n <= 0xffffffff
269275
| isDiscardable (PrimOp {primOp = F.PrimCall p, args, ...}) =
270276
Primitives.isDiscardableWithArgs (p, List.map getPrimEffect args)
271277
| isDiscardable (PrimOp {primOp = F.JsCallOp, args = e :: _, ...}) =

src/primitives.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ do
863863
srcname = "Array_array",
864864
type = { vars = {TV.a}, args = {intA, TV.a}, results = {array(TV.a)} },
865865
mayraise = true,
866-
discardable = false,
866+
discardable = false, -- There is a special rule in CSyntax.isDiscardable
867867
},
868868
{
869869
name = "Unsafe.cast",

0 commit comments

Comments
 (0)