# Incorrect location of an error when the line is terminated by semicolon

**URL:** <https://discourse.julialang.org/t/incorrect-location-of-an-error-when-the-line-is-terminated-by-semicolon/127548>\
**Category:** General Usage\
**Tags:** bug\
**Created:** [March 31, 2025, 1:33pm UTC](https://discourse.julialang.org/t/incorrect-location-of-an-error-when-the-line-is-terminated-by-semicolon/127548 "2025-03-31T13:33:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![merement](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/merement/32/7059_2.png) [@merement](https://discourse.julialang.org/u/merement)\
**Post date:** [March 31, 2025, 1:33pm UTC](https://discourse.julialang.org/t/incorrect-location-of-an-error-when-the-line-is-terminated-by-semicolon/127548/1 "2025-03-31T13:33:37Z")

</div>

Possible bug?  
In the code,

```julia
a = 1
b ::Dict{String => String} = Dict();

```

Julia reports an error in line 1. More precisely, in the previously executed line. Without the semicolon after `Dict()`, the error is correctly reported in line 2.

More details

```julia
➜ echo -e "a = 1\n b ::Dict{String => String} = Dict();\n" > a.jl && julia a.jl
ERROR: LoadError: TypeError: in Type, in parameter, expected Type, got a value of type Pair{DataType, DataType}
Stacktrace:
 [1] top-level scope
   @ ~/..../a.jl:1
in expression starting at /home/..../a.jl:1

➜ echo -e "a = 1\n b ::Dict{String => String} = Dict()\n" > a.jl && julia a.jl
ERROR: LoadError: TypeError: in Type, in parameter, expected Type, got a value of type Pair{DataType, DataType}
Stacktrace:
 [1] top-level scope
   @ ~/..../a.jl:2
in expression starting at /home/..../a.jl:2

```

With syntax errors, the error is pinpointed correctly regardless of whether the semicolon is present or not.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [March 31, 2025, 2:50pm UTC](https://discourse.julialang.org/t/incorrect-location-of-an-error-when-the-line-is-terminated-by-semicolon/127548/2 "2025-03-31T14:50:31Z")

</div>

```julia
julia> Meta.parseall("a = 1\n b ::Dict{String => String} = Dict();\n")
:($(Expr(:toplevel, :(#= none:1 =#), :(a = 1), :(#= none:1 =#), :($(Expr(:toplevel, :(b::Dict{String => String} = Dict())))))))

julia> Meta.parseall("a = 1\n b ::Dict{String => String} = Dict()\n")
:($(Expr(:toplevel, :(#= none:1 =#), :(a = 1), :(#= none:2 =#), :(b::Dict{String => String} = Dict()))))

```

Note the duplicated internal line number `:(#= none:1 =#)` preceding the `;` chain; that is showing up in the stacktrace. Good news is the expected behavior can happen a couple versions later; bad news it seems there’s some hurdles in the way of backports to released versions: [parser gives wrong line number of codes with semi-colon · Issue #57645 · JuliaLang/julia](https://github.com/JuliaLang/julia/issues/57645). At least semicolons aren’t necessary for delimiting lines in a multiline string and don’t suppress output in this context, so you could do without them for now.

---

<div class="post-metadata">

**Author:** ![merement](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/merement/32/7059_2.png) [@merement](https://discourse.julialang.org/u/merement)\
**Post date:** [March 31, 2025, 3:28pm UTC](https://discourse.julialang.org/t/incorrect-location-of-an-error-when-the-line-is-terminated-by-semicolon/127548/3 "2025-03-31T15:28:36Z")

</div>

Oh, snap. I quickly searched and found nothing, so I wasn’t sure what to think about this. It’s good to know that it’s known.
