Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some small type inference improvements to allow for some basic static compiling #491

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@
end

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

Expand Down Expand Up @@ -1602,7 +1602,7 @@
ckind == K"vcat" ? K"typed_vcat" :
ckind == K"comprehension" ? K"typed_comprehension" :
ckind == K"ncat" ? K"typed_ncat" :
internal_error("unrecognized kind in parse_cat ", ckind)
internal_error("unrecognized kind in parse_cat ", string(ckind))
emit(ps, mark, outk, cflags)
check_ncat_compat(ps, mark, ckind)
end
Expand Down Expand Up @@ -2020,7 +2020,7 @@
elseif word == K"do"
bump(ps, TRIVIA_FLAG, error="invalid `do` syntax")
else
internal_error("unhandled reserved word ", word)
internal_error("unhandled reserved word ", string(word))

Check warning on line 2023 in src/parser.jl

View check run for this annotation

Codecov / codecov/patch

src/parser.jl#L2023

Added line #L2023 was not covered by tests
end
end

Expand Down
5 changes: 2 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ _unsafe_wrap_substring(s) = (s.offset, unsafe_wrap(Vector{UInt8}, s.string))
#--------------------------------------------------
#
# Internal error, used as assertion failure for cases we expect can't happen.
@noinline function internal_error(strs...)
@noinline function internal_error(strs::Vararg{String, N}) where {N}
error("Internal error: ", strs...)
end

# Like @assert, but always enabled and calls internal_error()
macro check(ex, msgs...)
msg = isempty(msgs) ? ex : msgs[1]
if isa(msg, AbstractString)
msg = msg
msg = String(msg)
elseif !isempty(msgs) && (isa(msg, Expr) || isa(msg, Symbol))
msg = :(string($(esc(msg))))
else
Expand Down Expand Up @@ -133,4 +133,3 @@ function _printstyled(io::IO, text; fgcolor=nothing, bgcolor=nothing, href=nothi
first = false
end
end

Loading