Thank's to @Varo's issue here I found another workaround to this bug (I think it is)
The raised error seems due to a too long if statement. Splitting this calculation into 2 more little one and a third one to compute the global test works.