You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Direct return of struct literal with embedded function calls fails to compile #409
Returning a struct literal directly from a function, where one or more fields are initialized with function calls, fails to compile. The compiler produces FLOW compilation failed with no further diagnostic.
The struct literal should be constructed with the function call results and returned successfully.
Workaround
Assign each function call to a local variable first, then use those variables in the struct literal:
export function make_foo(X: Matrix, y: ptr<f32>) -> Foo {
let x_copy: Matrix = matrix_copy(X)
let y_copy: ptr<f32> = array_copy_f32(y, X.rows)
let result: Foo = Foo {
x: x_copy,
y: y_copy,
n: X.rows
}
return result
}
This compiles and works correctly.
Impact
Discovered in flow-scikit radius_neighbors_regressor_fit. The pattern of returning a struct literal with function calls is common and natural, so this limitation affects many use cases.
Activity
test: regression tests for struct literal return with calls (#409)
fix: multiple compiler bugs and project conventions (#419)
godofecht commentedon Aug 11, 2026
Fixed in PR #419 (merged).