Skip to content

Commit 7e444ae

Browse files
authored
Merge pull request #468 from JuliaLang/fe/backport-release-0.4
Backport release 0.4
2 parents b1c758c + e32b448 commit 7e444ae

File tree

8 files changed

+48
-13
lines changed

8 files changed

+48
-13
lines changed

.github/workflows/CI.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ jobs:
2323
- '1.6'
2424
- '1.7'
2525
- '1.8'
26+
- '1.9'
2627
- '1'
28+
- 'pre'
2729
- 'nightly'
2830
os:
2931
- ubuntu-latest
@@ -37,6 +39,7 @@ jobs:
3739
# - 1.0
3840
# - 1.6
3941
# - 1
42+
# - pre
4043
# - nightly
4144
# but remove some configurations from the build matrix to reduce CI time.
4245
# See https://github.com/marketplace/actions/setup-julia-environment
@@ -47,6 +50,7 @@ jobs:
4750
- {os: 'macOS-latest', version: '1.5'}
4851
- {os: 'macOS-latest', version: '1.7'}
4952
- {os: 'macOS-latest', version: '1.8'}
53+
- {os: 'macOS-latest', version: '1.9'}
5054
# MacOS not available on x86
5155
- {os: 'macOS-latest', arch: 'x86'}
5256
- {os: 'windows-latest', version: '1.1'}
@@ -56,16 +60,18 @@ jobs:
5660
- {os: 'windows-latest', version: '1.5'}
5761
- {os: 'windows-latest', version: '1.7'}
5862
- {os: 'windows-latest', version: '1.8'}
63+
- {os: 'windows-latest', version: '1.9'}
5964
- {os: 'ubuntu-latest', version: '1.1', arch: 'x86'}
6065
- {os: 'ubuntu-latest', version: '1.2', arch: 'x86'}
6166
- {os: 'ubuntu-latest', version: '1.3', arch: 'x86'}
6267
- {os: 'ubuntu-latest', version: '1.4', arch: 'x86'}
6368
- {os: 'ubuntu-latest', version: '1.5', arch: 'x86'}
6469
- {os: 'ubuntu-latest', version: '1.7', arch: 'x86'}
6570
- {os: 'ubuntu-latest', version: '1.8', arch: 'x86'}
71+
- {os: 'ubuntu-latest', version: '1.9', arch: 'x86'}
6672
steps:
6773
- uses: actions/checkout@v2
68-
- uses: julia-actions/setup-julia@v1
74+
- uses: julia-actions/setup-julia@v2
6975
with:
7076
version: ${{ matrix.version }}
7177
arch: ${{ matrix.arch }}
@@ -92,7 +98,7 @@ jobs:
9298
fail-fast: false
9399
steps:
94100
- uses: actions/checkout@v2
95-
- uses: julia-actions/setup-julia@v1
101+
- uses: julia-actions/setup-julia@v2
96102
with:
97103
version: 1.6
98104
arch: x64

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "JuliaSyntax"
22
uuid = "70703baa-626e-46a2-a12c-08ffd08c73b4"
33
authors = ["Claire Foster <[email protected]> and contributors"]
4-
version = "0.4.8"
4+
version = "0.4.9"
55

66
[compat]
77
julia = "1.0"

src/parse_stream.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ function ParseStream(text::AbstractString, index::Integer=1; version=VERSION)
314314
end
315315

316316
# IO-based cases
317-
function ParseStream(io::IOBuffer; version=VERSION)
317+
# TODO: switch ParseStream to use a Memory internally on newer versions of Julia
318+
VERSION < v"1.11.0-DEV.753" && function ParseStream(io::IOBuffer; version=VERSION)
318319
ParseStream(io.data, io, position(io)+1, version)
319320
end
320321
function ParseStream(io::Base.GenericIOBuffer; version=VERSION)
@@ -475,7 +476,7 @@ end
475476
end
476477

477478
"""
478-
peek(stream [, n=1]; skip_newlines=false)
479+
peek(stream::ParseStream [, n=1]; skip_newlines=false)
479480

480481
Look ahead in the stream `n` tokens, returning the token kind. Comments and
481482
non-newline whitespace are skipped automatically. Whitespace containing a

src/parser.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ function parse_unary(ps::ParseState)
12111211
# -2*x ==> (call-i -2 * x)
12121212
# +0xff ==> 0xff
12131213
bump_glue(ps, kind(t2), EMPTY_FLAGS)
1214+
parse_factor_with_initial_ex(ps, mark)
12141215
end
12151216
return
12161217
end

src/tokenize.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,10 @@ function lex_whitespace(l::Lexer, c)
733733
if c == '\n'
734734
k = K"NewlineWs"
735735
end
736-
pc = peekchar(l)
736+
pc, ppc = dpeekchar(l)
737737
# stop on non whitespace and limit to a single newline in a token
738-
if !iswhitespace(pc) || (k == K"NewlineWs" && pc == '\n')
738+
if !iswhitespace(pc) ||
739+
(k == K"NewlineWs" && (pc == '\n' || (pc == '\r' && ppc == '\n')))
739740
break
740741
end
741742
c = readchar(l)
@@ -747,8 +748,8 @@ function lex_comment(l::Lexer)
747748
if peekchar(l) != '='
748749
valid = true
749750
while true
750-
pc = peekchar(l)
751-
if pc == '\n' || pc == EOF_CHAR
751+
pc, ppc = dpeekchar(l)
752+
if pc == '\n' || (pc == '\r' && ppc == '\n') || pc == EOF_CHAR
752753
return emit(l, valid ? K"Comment" : K"ErrorInvalidUTF8")
753754
end
754755
valid &= isvalid(pc)

test/parse_packages.jl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ end
99
end
1010

1111
base_path = let
12-
p = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "base")
12+
p = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "base")
1313
if !isdir(p)
1414
# For julia 1.9 images.
15-
p = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "src", "base")
15+
p = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "src", "base")
1616
if !isdir(p)
1717
error("source for Julia base not found")
1818
end
@@ -40,8 +40,21 @@ base_tests_path = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test")
4040
end
4141

4242
if endswith(f, "core.jl")
43-
# Loose comparison due to `for f() = 1:3` syntax
44-
return exprs_roughly_equal
43+
# The test
44+
# @test Union{Tuple{T}, Tuple{T,Int}} where {T} === widen_diagonal(Union{Tuple{T}, Tuple{T,Int}} where {T})
45+
# depends on a JuliaSyntax bugfix and parses differently (wrong) using
46+
# flisp. This was added in julia#52228 and backported in julia#52045
47+
if v"1.10.0-rc1.39" <= VERSION
48+
return nothing
49+
else
50+
# Loose comparison due to `for f() = 1:3` syntax
51+
return exprs_roughly_equal
52+
end
53+
end
54+
55+
# subtype.jl also depends on the where precedence JuliaSyntax bugfix as of julia#53034
56+
if endswith(f, "subtype.jl") && v"1.11.0-DEV.1382" <= VERSION
57+
return nothing
4558
end
4659

4760
return exprs_equal_no_linenum

test/parser.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ tests = [
212212
"-0b10010" => "(call-pre - 0x12)"
213213
"-0o22" => "(call-pre - 0x12)"
214214
"-0x12" => "(call-pre - 0x12)"
215+
"-1::T" => "(::-i -1 T)"
215216
# Standalone dotted operators are parsed as (|.| op)
216217
".+" => "(. +)"
217218
".+\n" => "(. +)"

test/tokenize.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ end
161161
@test untokenize(tok(str), str)==">>"
162162
end
163163

164+
@testset "tokenize newlines" begin
165+
n = "\n"
166+
rn = "\r\n"
167+
nl = K"NewlineWs"
168+
for i in 0:5
169+
j = 5 - i
170+
@test toks(n^i * rn^j) == vcat(fill(n => nl, i), fill(rn => nl, j))
171+
@test toks(rn^i * n^j) == vcat(fill(rn => nl, i), fill(n => nl, j))
172+
end
173+
end
164174

165175
@testset "test added operators" begin
166176
@test tok("1+=2", 2).kind == K"+="
@@ -219,6 +229,8 @@ end
219229
@test toks("#= #= =#") == ["#= #= =#"=>K"ErrorEofMultiComment"]
220230
@test toks("#=#==#=#") == ["#=#==#=#"=>K"Comment"]
221231
@test toks("#=#==#=") == ["#=#==#="=>K"ErrorEofMultiComment"]
232+
# comment terminated by \r\n
233+
@test toks("#\r\n") == ["#" => K"Comment", "\r\n" => K"NewlineWs"]
222234
end
223235

224236

0 commit comments

Comments
 (0)