@@ -137,18 +137,22 @@ end
137137const _debug_log = Ref {Union{Nothing,IO}} (nothing )
138138
139139function core_parser_hook (code, filename:: String , lineno:: Int , offset:: Int , options:: Symbol )
140+ # TODO : Check that we do all this input wrangling without copying the
141+ # code buffer
142+ if code isa Core. SimpleVector
143+ # The C entry points will pass us this form.
144+ (ptr,len) = code
145+ code = String (unsafe_wrap (Array, ptr, len))
146+ elseif ! (code isa String || code isa SubString || code isa Vector{UInt8})
147+ # For non-Base string types, convert to UTF-8 encoding, using an
148+ # invokelatest to avoid world age issues.
149+ code = Base. invokelatest (String, code):: String
150+ end
151+ core_parser_hook (code, filename, lineno, offset, options)
152+ end
153+
154+ function core_parser_hook (code:: String , filename:: String , lineno:: Int , offset:: Int , options:: Symbol ):: Core.SimpleVector
140155 try
141- # TODO : Check that we do all this input wrangling without copying the
142- # code buffer
143- if code isa Core. SimpleVector
144- # The C entry points will pass us this form.
145- (ptr,len) = code
146- code = String (unsafe_wrap (Array, ptr, len))
147- elseif ! (code isa String || code isa SubString || code isa Vector{UInt8})
148- # For non-Base string types, convert to UTF-8 encoding, using an
149- # invokelatest to avoid world age issues.
150- code = Base. invokelatest (String, code)
151- end
152156 if ! isnothing (_debug_log[])
153157 print (_debug_log[], """
154158 #-#-#-------------------------------
@@ -213,7 +217,7 @@ function core_parser_hook(code, filename::String, lineno::Int, offset::Int, opti
213217 # * appends the error message
214218 topex = Expr (tree)
215219 @assert topex. head == :toplevel
216- i = findfirst (_has_nested_error, topex. args)
220+ i = findfirst (_has_nested_error, topex. args):: Int
217221 if i > 1 && topex. args[i- 1 ] isa LineNumberNode
218222 i -= 1
219223 end
399403# Convenience functions to mirror `JuliaSyntax.parsestmt(Expr, ...)` in simple cases.
400404fl_parse (:: Type{Expr} , args... ; kws... ) = fl_parse (args... ; kws... )
401405fl_parseall (:: Type{Expr} , args... ; kws... ) = fl_parseall (args... ; kws... )
402-
0 commit comments