Hi Guys,
I’m new-ish to Julia and so far things have been great, but this syntax error has really stumped me.
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?
Thanks in advance!
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!
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!
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
Stacktrace:
[1] top-level scope
@ none:1
One way to avoid the error is simply adding parenthesis:
julia> println("$((1,2))")
(1, 2)