Syntax error: 'invalid interpolation syntax' when using include()

Hi Guys,
I’m new-ish to Julia and so far things have been great, but this syntax error has really stumped me. :man_shrugging:t3:

Here’s the background.

  • I have several files called _Aa.jl, _Bb.jl, and so on.
  • Each one contains a module of the same name (_Aa, _Bb,…).
  • I can import the modules in most cases with no trouble:

@isdefined _Aa 

However, when I try to do this for a file called “_MSEn.jl” the following error is thrown:

ERROR: syntax: invalid interpolation syntax

And the file definitely exists…


Could somebody please explain why this happens and/or what I have overlooked? :pray: :pray:

Thanks in advance! :slightly_smiling_face:

It looks to me like you probably have a typo in the file. What does it contain? That error message suggests that you’ve got a string containing a $ and Julia is trying to interpolate something incorrectly.


Thank you so much magister-ludi! :raised_hands:t3:
That was the problem exactly.

I had misinterpreted the error as relating to the filename string (i.e. include(“filename”)) as opposed to strings contained within the file…

Your help is really appreciated! :slightly_smiling_face: :+1:t3:

No worries. There are a lot of complaints about Julia’s error messages, but as with any language, it takes time and practice to be able to interpret them productively.

I bumped into the same error today. I was able to reproduce it with:

julia> println("$(1,2)")
ERROR: syntax: invalid interpolation syntax
 [1] top-level scope
   @ none:1

One way to avoid the error is simply adding parenthesis:

julia> println("$((1,2))")
(1, 2)