Applescript error -1708 when calling a function I have written a script for Spotify with a subroutine

tell application "Spotify"
    ⋮
    silentVolume(tmpDur)
    ⋮
end tell

on silentVolume(tmpDur)
    tell application "Spotify"
        ⋮
        set tmpDur to ((duration of current track) / 1000)
        ⋮
    end tell
end silentVolume


Two problems with this


When I call silentVolume with a float I get an error -1708 and the error message (translated to English so this is an approximation) "Spotify encountered an error. Cannot continue silentVolume". Why?
silentVolume doesn't seem to inherit the context (tell application "Spotify") of the main function. Why?


Initially this subroutine was part of the main function and then it worked fine but I needed a recursive solution, therefore I had to break it out into a separate method.
It was a problem with the scope. This question got me on the right way. I needed to change the call to the subroutine to

my silentVolume (tmpDur)


and then now works as expected. Leave it here as a future reference for anyone googling error -1708.