Skip to content

Commit 992dc07

Browse files
authored
add some small type inference improvements to allow for some basic static compiling (#491)
1 parent 6532515 commit 992dc07

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/parser.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ function parse_block(ps::ParseState, down=parse_eq, mark=position(ps))
484484
end
485485

486486
# Parse a block, but leave emitting the block up to the caller.
487-
function parse_block_inner(ps::ParseState, down)
487+
function parse_block_inner(ps::ParseState, down::F) where {F <: Function}
488488
parse_Nary(ps, down, KSet"NewlineWs ;", KSet"end else elseif catch finally")
489489
end
490490

@@ -1602,7 +1602,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
16021602
ckind == K"vcat" ? K"typed_vcat" :
16031603
ckind == K"comprehension" ? K"typed_comprehension" :
16041604
ckind == K"ncat" ? K"typed_ncat" :
1605-
internal_error("unrecognized kind in parse_cat ", ckind)
1605+
internal_error("unrecognized kind in parse_cat ", string(ckind))
16061606
emit(ps, mark, outk, cflags)
16071607
check_ncat_compat(ps, mark, ckind)
16081608
end
@@ -2020,7 +2020,7 @@ function parse_resword(ps::ParseState)
20202020
elseif word == K"do"
20212021
bump(ps, TRIVIA_FLAG, error="invalid `do` syntax")
20222022
else
2023-
internal_error("unhandled reserved word ", word)
2023+
internal_error("unhandled reserved word ", string(word))
20242024
end
20252025
end
20262026

src/utils.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ _unsafe_wrap_substring(s) = (s.offset, unsafe_wrap(Vector{UInt8}, s.string))
1919
#--------------------------------------------------
2020
#
2121
# Internal error, used as assertion failure for cases we expect can't happen.
22-
@noinline function internal_error(strs...)
22+
@noinline function internal_error(strs::Vararg{String, N}) where {N}
2323
error("Internal error: ", strs...)
2424
end
2525

2626
# Like @assert, but always enabled and calls internal_error()
2727
macro check(ex, msgs...)
2828
msg = isempty(msgs) ? ex : msgs[1]
2929
if isa(msg, AbstractString)
30-
msg = msg
30+
msg = String(msg)
3131
elseif !isempty(msgs) && (isa(msg, Expr) || isa(msg, Symbol))
3232
msg = :(string($(esc(msg))))
3333
else
@@ -133,4 +133,3 @@ function _printstyled(io::IO, text; fgcolor=nothing, bgcolor=nothing, href=nothi
133133
first = false
134134
end
135135
end
136-

0 commit comments

Comments
 (0)