Skip to content
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
2 changes: 1 addition & 1 deletion src/parse_stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion test/parse_stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Loading