Skip to content

Allow implicit conversions from String => os.*Path to allow multiple segments if the string is a literal (500USD Bounty) #294

@lihaoyi

Description

@lihaoyi

From the maintainer Li Haoyi: I'm putting a 500USD bounty on this issue, payable by bank transfer on a merged PR implementing this.


Currently, os.pwd / "foo/bar/baz" fails. We do this to guard against people accidentally doing os.pwd / myStringValue and accidentally getting path traversal problems and such, and for people to explicitly say os.pwd / os.SubPath(myStringValue) or os.pwd / os.RelPath(myStringValue).

But if the RHS of the / is a literal string, there is no risk, and we should allow people to say os.pwd / "foo/bar/baz" instead of the more verbose os.pwd / "foo" / "bar" / "baz". This can be done by making the implicit conversion from String to SubPath/RelPath a macro that checks whether the RHS is a literal, and if so goes through a different code path that allows it to contain multiple segments automatically

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions