Touch of death help

I have tried very hard to debug my code, but I have not found the error.
The message is:

Unreachable after return

Here is my code:

loop {
    var enemy = this.findNearestEnemy();
    if (enemy) {
        var distance = this.distanceTo(enemy);
        if (distance < 15) {
            // Cast "drain-life" on the enemy.
            this.cast("drain-life", this.findNearestEnemy());
        }
        else {
            // Attack the enemy with your staff.
            this.attack(enemy);
        }
    }
}

At least edit your post using : “FAQ - Check Before Posting” pinned post

Edited Feintys post to have better punctuation and indentation.

I don’t understand the error though. There is no return-statement in your code. Can’t help you here, sorry.

Same for me, no evident mistake.
I could just advise you to replace:
this.cast("drain-life", this.findNearestEnemy());
by
this.cast("drain-life", enemy);

Are you sure you show us all the code ? Where the error took place in the code ?

Yes this is all my code and it says

Unreachable 'while' after 'return'

Reclassified as bug.

You have this at the top of your code from hitting the “Comment out my code” button on the infinite loop modal at some point:

return;  // Commented out to stop infinite loop.

So that’s why it’s giving you that message.

I found this out recently and fixed my code btw thanks for the help