Your example works for me:
julia> my_function(2,0)
Quantum Circuit Object:
id: c6f6da90-8206-11ed-1053-3bc9d78927f5
qubit_count: 2
bit_count: 0
q[1]:
q[2]:
The error message you have doesn’t make sense with the code, maybe try to run it all again?