Skip to content

Docstrings with backslashes yield "invalid escape sequence" upon precompilation #29200

Closed
@timholy

Description

Non-contaminating reproducer: start julia with

$ DEPOT_PATH=/tmp/pkgs julia

and then

(v1.0) pkg> generate Backslash
Generating project Backslash:
    Backslash/Project.toml
    Backslash/src/Backslash.jl

julia> edit("Backslash/src/Backslash.jl")

Then add a docstring to greet:

"""
This is a docstring with a backslash: x = A \ b
"""
greet() = print("Hello World!")

(I inserted the spaces between backticks to prevent confusing the markdown renderer here, but you should take them out when you try this.)

And then finally:

julia> using Backslash
[ Info: Precompiling Backslash [f5b45752-b8ef-11e8-19fb-2fec647fc92b]
ERROR: LoadError: syntax: invalid escape sequence
Stacktrace:
 [1] include at ./boot.jl:317 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1041
 [3] include(::Module, ::String) at ./sysimg.jl:29
 [4] top-level scope at none:2
 [5] eval at ./boot.jl:319 [inlined]
 [6] eval(::Expr) at ./client.jl:389
 [7] top-level scope at ./none:3
in expression starting at /tmp/Backslash/src/Backslash.jl:5
ERROR: Failed to precompile Backslash [f5b45752-b8ef-11e8-19fb-2fec647fc92b] to /tmp/pkgs/compiled/v1.0/Backslash/JC5Xv.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] macro expansion at ./logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at ./loading.jl:1187
 [4] _require(::Base.PkgId) at ./logging.jl:311
 [5] require(::Base.PkgId) at ./loading.jl:855
 [6] macro expansion at ./logging.jl:311 [inlined]
 [7] require(::Module, ::Symbol) at ./loading.jl:837

Now, perhaps this is deliberate (you can fix it by changing \ to \\), but it seems a little strange to have precompilation fail due to the formatting of the docstring.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions