diff --git a/src/parse_stream.jl b/src/parse_stream.jl index b1594ea2..5b04b42c 100644 --- a/src/parse_stream.jl +++ b/src/parse_stream.jl @@ -391,7 +391,7 @@ function ParseStream(text::String, index::Integer=1; version=VERSION) ParseStream(unsafe_wrap(Vector{UInt8}, text), text, index, version) end -function ParseStream(text::SubString, index::Integer=1; version=VERSION) +function ParseStream(text::SubString{String}, index::Integer=1; version=VERSION) # See also IOBuffer(SubString("x")) ParseStream(unsafe_wrap(Vector{UInt8}, pointer(text), sizeof(text)), text, index, version) diff --git a/test/parse_stream.jl b/test/parse_stream.jl index f7c0bd60..f5148f27 100644 --- a/test/parse_stream.jl +++ b/test/parse_stream.jl @@ -7,7 +7,8 @@ using JuliaSyntax: ParseStream, peek, peek_token, bump, bump_trivia, bump_invisible, emit, emit_diagnostic, TRIVIA_FLAG, INFIX_FLAG, - ParseStreamPosition, first_child_position, last_child_position + ParseStreamPosition, first_child_position, last_child_position, + parsestmt # Here we manually issue parse events in the order the Julia parser would issue # them @@ -147,3 +148,13 @@ end @test first_child_position(st, position(st)) == ParseStreamPosition(4, 1) @test last_child_position(st, position(st)) == ParseStreamPosition(7, 2) end + +@testset "SubString{GenericString} (issue #505)" begin + x = Test.GenericString("1 2") + @test x == "1 2" + y = split(x)[1] + @test y == "1" + @test y isa SubString{GenericString} + @test ParseStream(y) isa ParseStream + @test parsestmt(Expr, y) == parsestmt(Expr, "1") +end