Skip to content

Respect Unix filename separators in path component helpers #855

Closed

Description

@LunaStev

Problem

path_is_abs follows target-specific rules, but path_is_sep treats both slash and backslash as separators on every target. Consequently, basename/dirname/join operations misinterpret valid Unix filenames containing a backslash.

Starting points: separator policy and component analysis. #529 fixed absolute-path classification, not this component-parsing mismatch.

Reproduction

Audited canonical master 7a8361d5c10ec3e66fc9fe4a5801622afb6bf631 on Linux amd64. Reproduced with the public v0.2.1-pre-beta Linux amd64 compiler (LLVM 21.1.8) and this checkout's std; the compiler/std source trees match the release. Set WAVEC to the extracted package's absolute wavec path and run commands from the repository root.

import("std::path::analyze")::{path_basename_start, path_basename_len};
fun main() -> i32 {
    println("start={} len={}", path_basename_start("a\\b"), path_basename_len("a\\b"));
    return 0;
}

Run "$WAVEC" --std-root "$PWD/std" run repro.wave. Linux output is start=2 len=1, although a\b is one three-byte filename component. Native Unix interpretation would give start=0 len=3. A leading backslash is also treated as a root by component analysis while path_is_abs returns false.

Scope

Use a consistent target policy for basename, dirname, extension and joining while preserving Windows slash/backslash support. This is a compatibility change for callers using Unix builds to manipulate Windows-style text. Please mention @LunaStev to discuss the compatibility policy before starting implementation. Difficulty: medium.

Completion criteria

  • Unix backslashes remain part of filename components across the affected helpers.
  • Windows separator and drive-root behavior remains covered by native-target tests.
  • Root detection and absolute-path classification no longer contradict one another for a leading backslash on Unix.

Activity

  1. added
    bug
    help wanted
    on Oct 5, 2026
  2. added a commit that references this issue on Nov 11, 2026
    d3aa515
  3. added a commit that references this issue on Nov 13, 2026
    69a67c6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions