@@ -21,6 +21,17 @@ let private transformExprList com ctx xs =
2121let private transformExprOpt com ctx opt =
2222 trampolineOptionMap ( transformExpr com ctx []) opt
2323
24+ let private transformAddressedValue ( com : IFableCompiler ) ( ctx : Context ) ( fsExpr : FSharpExpr ) =
25+ trampoline {
26+ match fsExpr with
27+ | ArrayElementAddress( elementType, arrayExpr, indexExpr) ->
28+ let! arrayExpr = transformExpr com ctx [] arrayExpr
29+ let! indexExpr = transformExpr com ctx [] indexExpr
30+ let typ = makeType ctx.GenericArgs elementType
31+ return Replacements.Api.getArrayElement com ctx ( makeRangeFrom fsExpr) typ arrayExpr indexExpr
32+ | _ -> return ! transformExpr com ctx [] fsExpr
33+ }
34+
2435let private transformBaseConsCall
2536 com
2637 ctx
@@ -588,7 +599,7 @@ let private transformUnionCaseTest
588599 ( unionCase : FSharpUnionCase )
589600 =
590601 trampoline {
591- let! unionExpr = transformExpr com ctx [] unionExpr
602+ let! unionExpr = transformAddressedValue com ctx unionExpr
592603 let unionPattern = getUnionPattern fsType unionCase
593604
594605 match unionPattern with
@@ -1156,6 +1167,11 @@ let private transformExpr (com: IFableCompiler) (ctx: Context) appliedGenArgs fs
11561167 " This explicit constructor uses a self identifier (`new() as x`), which Fable only supports on JavaScript, TypeScript and Python, in a class with no base class and without [<AttachMembers>]."
11571168 |> addErrorAndReturnNull com ctx.InlinePath r
11581169
1170+ | ArrayElementAddress _ ->
1171+ return
1172+ " Taking the address of an array element is not supported"
1173+ |> addErrorAndReturnNull com ctx.InlinePath ( makeRangeFrom fsExpr)
1174+
11591175 | FSharpExprPatterns.Value var ->
11601176 let r = makeRangeFrom fsExpr
11611177
@@ -1619,7 +1635,7 @@ let private transformExpr (com: IFableCompiler) (ctx: Context) appliedGenArgs fs
16191635 | IgnoreAddressOf inner when com.Options.Language <> Rust -> inner
16201636 | _ -> callee
16211637
1622- let! transformedCallee = transformExpr com ctx [] callee
1638+ let! transformedCallee = transformAddressedValue com ctx callee
16231639 let callee = derefByRefCallee com ctx r callee calleeType transformedCallee
16241640
16251641 let fieldName = calleeType.AnonRecordTypeDetails.SortedFieldNames[ fieldIndex]
@@ -1679,7 +1695,7 @@ let private transformExpr (com: IFableCompiler) (ctx: Context) appliedGenArgs fs
16791695 match tupleElemValue with
16801696 | Some( Fable.IdentExpr id as e) when not id.IsMutable -> return e
16811697 | _ ->
1682- let! tupleExpr = transformExpr com ctx [] tupleExpr
1698+ let! tupleExpr = transformAddressedValue com ctx tupleExpr
16831699 // let typ = makeType ctx.GenericArgs fsExpr.Type // Doesn't always work
16841700 let typ =
16851701 Seq.item tupleElemIndex tupleType.GenericArguments |> makeType ctx.GenericArgs
@@ -1690,7 +1706,7 @@ let private transformExpr (com: IFableCompiler) (ctx: Context) appliedGenArgs fs
16901706 let r = makeRangeFrom fsExpr
16911707 // let fieldType = makeType ctx.GenericArgs fsExpr.Type // Doesn't always work
16921708 let fieldType = resolveFieldType ctx unionType field.FieldType
1693- let! unionExpr = transformExpr com ctx [] unionExpr
1709+ let! unionExpr = transformAddressedValue com ctx unionExpr
16941710
16951711 match getUnionPattern unionType unionCase with
16961712 | ErasedUnionCase ->
0 commit comments