Type checking error when typed slices used as function parameters #38

Closed
opened 2025-09-19 16:01:42 +00:00 by Furkan · 1 comment
import io
import mem

myfunc(arr []int) -> int {
    return arr[0]
}

main() {
	arr := new(int, 8)
	arr[0] = 32
    io.write(myfunc(arr))
}

Error:

io.write(myfunc(arr))

╰─ Expected parameter 'arr' of type '[]int64' (encountered '[]int64')

``` import io import mem myfunc(arr []int) -> int { return arr[0] } main() { arr := new(int, 8) arr[0] = 32 io.write(myfunc(arr)) } ``` Error: io.write(myfunc(arr)) ┬ ╰─ Expected parameter 'arr' of type '[]int64' (encountered '[]int64')
ed self-assigned this 2025-09-19 18:07:24 +00:00
Owner
Fixed in https://git.urbach.dev/cli/q/commit/b556e2162c3c0c5b394617c5f3291774be9a78b8. Test: https://git.urbach.dev/cli/q/src/commit/b556e2162c3c0c5b394617c5f3291774be9a78b8/tests/int-array-parameter.q
ed added spent time 2025-09-20 07:35:53 +00:00
30 minutes
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Total time spent: 30 minutes
ed
30 minutes
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cli/q#38
No description provided.