Skip to content

Remove the duplicated dead mac branch in Os.detect #938

Open

Description

@gciatto

Context

Os.detect(description: String) in core/src/commonMain/kotlin/it/unibo/tuprolog/Os.kt maps a free-form OS description (on the JVM, the os.name system property, see core/src/jvmMain/kotlin/it/unibo/tuprolog/Introspection.kt) to an Os value. Its when has the same mac branch twice:

description.contains("mac", ignoreCase = true) -> MAC
description.contains("mac", ignoreCase = true) -> MAC   // unreachable duplicate

The second branch can never match, because the first one already handles every input that contains mac. It does not change behavior, but it is dead code and looks like a copy-paste slip.

Expected

Each OS pattern appears once in Os.detect.

Possible approach

Delete the duplicate line. Optional: check whether another pattern was meant to go there (e.g. darwin or os x). Before adding darwin, note that the win branch is checked earlier and also matches "darwin". Today that cannot happen, because the only caller passes the JVM's os.name (Mac OS X on macOS).

Affected module: :core.


Original description

Os.detect contains a duplicated, dead mac match branch. Spotted during the documentation pass; not fixed in commit 5dfb787.

Activity

  1. gciatto commented on Oct 4, 2026

    @gciatto
    ContributorAuthor

    Triage: this is still valid on current master. The duplicated mac branch is still in core/src/commonMain/kotlin/it/unibo/tuprolog/Os.kt, since #929 (5dfb787) only added KDoc. I rewrote the description with more context and added labels.

    Triage performed by Claude Code on behalf of @gciatto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions