Fixes #2832
Current code silently converts -1 to 0, which is not needed and we should fail instead.
tree