Skip to content

Commit

Permalink
compiler: fix: the --opt-zcopy and --opt-zappend optimizations may ca…
Browse files Browse the repository at this point in the history
…use compile issues
  • Loading branch information
mertcandav committed Feb 25, 2025
1 parent f17928e commit 321b340
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/julec/opt/expr.jule
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,13 @@ impl exprOptimizer {
// Optimization of the dest argument belongs to the back-end.
if IsZCopyArray(m.Src.Model) {
mut ie := (&sema::SlicingExpr)(m.Src.Model)

// Special case: already optimized.
_, ok := (&ArrayAsSlice)(unsafe { *(*any)(&ie.Expr.Model) })
if ok {
ret
}

mut model := any(&ArrayAsSlice{
Expr: ie.Expr.Model,
})
Expand All @@ -887,6 +894,13 @@ impl exprOptimizer {
}
if IsZAppendArray(m.Elements.Model) {
mut ie := (&sema::SlicingExpr)(m.Elements.Model)

// Special case: already optimized.
_, ok := (&ArrayAsSlice)(unsafe { *(*any)(&ie.Expr.Model) })
if ok {
ret
}

mut model := any(&ArrayAsSlice{
Expr: ie.Expr.Model,
})
Expand Down

0 comments on commit 321b340

Please sign in to comment.