Just starting with Julia/VSCode - new to both so not quite sure where best to post this question.
I have an “invalid identifier” error in my first program which is diagnosed by GitHub CoPilot as below.
I suspect this is a “hallucination” - am I correct or am I misunderstanding something?
If it is a hallucination, should I report it, and if so to GitHub or Julia?
Many thanks!
@workspace /explain invalid identifier
The error "invalid identifier" is likely caused by the line:
squb += 2ub + 1
In Julia, you need to explicitly use the multiplication operator `*` between numbers and variables. So `2ub` is invalid; it should be `2 * ub`.
Here's the corrected line:
// ...existing code...
if (n > squb)
ub += 1
squb += 2 * ub + 1
end #
// ...existing code...
**Gotcha:**
Julia does not allow implicit multiplication between numbers and variables (unlike some math notation). Always use `*` for multiplication.
Let me know if you see this error elsewhere or need further help!
Developers of the original software can’t do anything about what Copilot learned to parrot. Most you can do is discuss it in a community, which won’t begin to fix Copilot’s outputs either. Unfortunately we’re personally responsible for factchecking generative AI, which isn’t great when you’re learning the language and its Manual is unwieldy.
In your case, you are correct and Copilot is wrong.
However, I recommend to only, if ever, use such syntax with a single literal number prepending a single variable. Once it’s two compound expressions juxtaposed, hard to know in advance if that’ll work.
julia> x = 3
3
julia> 4(x+1)
16
julia> (x+1)4
ERROR: ParseError:
# Error @ REPL[2]:1:6
(x+1)4
# ╙ ── extra tokens after end of expression
julia> y = 4
4
julia> (x+1)y
16
julia> y(x+1)
ERROR: MethodError: objects of type Int64 are not callable
Maybe you forgot to use an operator such as *, ^, %, / etc. ?
Didn’t read all of the specifics. The various AI models and agent tools that actually integrate with your code have different capabilities. In my experience, Copilot is far the worst of the lot. I have had decent experience using (in no particular order of merit) Cursor, Claude Code (terminal-based), and Augment within VS Code. All three can “figure out” Julia code and do simple focused things though not always with perfect results. In my own experience, Augment is far and away the best at “understanding” existing code and making suggestions or following “orders” with reasonable success rate (say 70%). Augment can often “understand” Julia’s error messages. In general, if the AI suggestions have gone seriously awry, which can certainly happen, don’t go down the rabbit hole with it. Pull back out. Work on the code some more yourself and then give AI very small, narrow tasks to do. Also, all 3 have ways to upload (or just type in) a kind of project guidance markdown set of guidelines you want the agent to follow. Enables a lot so best to look at some examples. It is VERY worthwhile to do this so the “agent” understands what you expect.
Augment can create or modify code, run it, and evaluate output. It is pretty shocking. Actually so can Claude Code though you may or may not find it easy to follow what is going on in the terminal.