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:
include("_Aa.jl")
Main._Aa

@isdefined _Aa 
true

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

include("_MSEn.jl")
ERROR: syntax: invalid interpolation syntax

And the file definitely exists…

isfile("_MSEn.jl")
true

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.

2 Likes

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.