Unexpected reserved keyword end

I was going through, I have double checked, copy exact same code, but this doesn’t seem to work when I compile, but it works normally in interactive mode, why is this happening?

defmodule Math do
  def double_each([head | tail]) do
    [head * 2 | double_each(tail)]
  end

  def double_each([]) do
    []
  end
end
== Compilation error in file math.exs ==
** (SyntaxError) math.exs:9:1: unexpected reserved word: end
    |
  9 | end
    | ^
    (elixir 1.15.4) lib/kernel/parallel_compiler.ex:377: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8

Works me for just fine in an .ex and .exs file. Maybe some unexpected invisible Unicode spacing character or something?

I copy-pasted the module and put in files and it compiled right away.

Not sure what exactly happened but I am unable to recreate this erro now, it seems to be working.