From d2816c7c88fdbeb2859d1ae1214462d7517bb126 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 9 Aug 2024 22:06:19 +0200 Subject: [PATCH 1/2] add some small type inference improvements to allow for some basic static compiling (#491) (cherry picked from commit 992dc07f3674e66c3799b8b1ed44f4c65fc67000, PR #491) --- src/parser.jl | 6 +++--- src/utils.jl | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/parser.jl b/src/parser.jl index e219fa67..ace363cc 100644 --- a/src/parser.jl +++ b/src/parser.jl @@ -475,7 +475,7 @@ function parse_block(ps::ParseState, down=parse_eq, mark=position(ps)) 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 @@ -1585,7 +1585,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false) 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 @@ -2011,7 +2011,7 @@ function parse_resword(ps::ParseState) 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)) end end diff --git a/src/utils.jl b/src/utils.jl index cee9689e..3f95c485 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -19,7 +19,7 @@ _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 @@ -27,7 +27,7 @@ end 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 @@ -133,4 +133,3 @@ function _printstyled(io::IO, text; fgcolor=nothing, bgcolor=nothing, href=nothi first = false end end - From 08b1126f12b487dde5c39019807e617843c79997 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Thu, 29 Aug 2024 13:15:39 +0200 Subject: [PATCH 2/2] Set version to 0.4.10. --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2f501027..a73a48e1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JuliaSyntax" uuid = "70703baa-626e-46a2-a12c-08ffd08c73b4" authors = ["Claire Foster and contributors"] -version = "0.4.9" +version = "0.4.10" [compat] julia = "1.0"