JuliaLang / JuliaLang/JuliaSyntax.jl
Ambiguous parsing of `x!==nothing`
- Dominant language
- Julia
- Stars
- 293
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Description
The following demonstrates a parser ambiguity that I think should throw a `ParseError` similar to how `1.+1` throws an error:
```julia
julia> x! = y -> y[1] = 1
#1 (generic function with 1 method)
julia> x! == nothing
false
julia> x!==nothing
ERROR: UndefVarError: `x` not defined
Stacktrace:
[1] top-level scope
@ REPL[4]:1
julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 32 × 13th Gen Intel(R) Core(TM) i9-13900HX
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, goldmont)
Threads: 32 default, 0 interactive, 16 GC (on 32 virtual cores)
Environment:
JULIA_NUM_THREADS = 32
JULIA_PKG_USE_CLI_GIT = true
```
In particular, does `x!==nothing` mean `x! == nothing` or `x !== nothing`? The parser silently assumes the latter. I personally always include whitespace, thus circumventing the issue, but I ran across a [line of code in NonlinearSolve.jl](https://github.com/SciML/NonlinearSolve.jl/blob/6740074b450d05ed5296cbc83d483f6288781fa2/src/descent/newton.jl#L80) that does not have whitespace, and so I was surprised the syntax was allowed!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.