Skip to content

Commit d2816c7

Browse files
KristofferCfredrikekre
authored andcommitted
add some small type inference improvements to allow for some basic static compiling (#491)
(cherry picked from commit 992dc07, PR #491)
1 parent 7e444ae commit d2816c7

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
@@ -475,7 +475,7 @@ function parse_block(ps::ParseState, down=parse_eq, mark=position(ps))
475475
end
476476

477477
# Parse a block, but leave emitting the block up to the caller.
478-
function parse_block_inner(ps::ParseState, down)
478+
function parse_block_inner(ps::ParseState, down::F) where {F <: Function}
479479
parse_Nary(ps, down, KSet"NewlineWs ;", KSet"end else elseif catch finally")
480480
end
481481

@@ -1585,7 +1585,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
15851585
ckind == K"vcat" ? K"typed_vcat" :
15861586
ckind == K"comprehension" ? K"typed_comprehension" :
15871587
ckind == K"ncat" ? K"typed_ncat" :
1588-
internal_error("unrecognized kind in parse_cat ", ckind)
1588+
internal_error("unrecognized kind in parse_cat ", string(ckind))
15891589
emit(ps, mark, outk, cflags)
15901590
check_ncat_compat(ps, mark, ckind)
15911591
end
@@ -2011,7 +2011,7 @@ function parse_resword(ps::ParseState)
20112011
elseif word == K"do"
20122012
bump(ps, TRIVIA_FLAG, error="invalid `do` syntax")
20132013
else
2014-
internal_error("unhandled reserved word ", word)
2014+
internal_error("unhandled reserved word ", string(word))
20152015
end
20162016
end
20172017

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)