Skip to content

Conversation

@Nikita-baghela07
Copy link
Contributor

Fix path normalization issue causing type mismatches on Windows

The same type was being seen as mismatching because of different path
representations, even though the paths referred to the same file.
For example, "src\cc.d.tl:6" vs ".\src/cc.d.tl:6" would be treated
as different files, causing type comparison failures.

Changes:

  • Move normalize function from tlcli/common.tl to teal/util.tl to make
    it available to the core type checking system
  • Update search_for() in require_file.tl to normalize returned paths
  • Update input.check() to normalize filenames before processing
  • Update search_and_load() to normalize paths before storing in cache
  • Add test case for path normalization with different separators

This ensures all file paths are converted to a canonical form before
being used for type checking, file loading, and module resolution,
preventing the same file from being treated as different files when
referenced with different path representations.

Fixes the issue where global_env_def modules would cause type errors
on Windows due to inconsistent path normalization between backslashes
and forward slashes, relative and absolute paths.

When records inherit from multiple interfaces that share a common parent
interface (diamond inheritance), the interface_list was incorrectly
containing duplicate entries. For example:

    local interface A end
    local interface B is A end
    local interface C is A end
    local record D is B, C end  -- interface_list was {B, A, C, A}

This was caused by the collect_interfaces function adding interfaces to
the list before checking if they had already been seen. The fix ensures
that interfaces are only added to the list if they haven't been
processed before, maintaining the correct order while eliminating
duplicates.

The interface_list for the example above now correctly contains {B, A, C}.

Changes:
- Fixed collect_interfaces() in context.lua and tl.lua to check seen[] before insert
- Added comprehensive test case for diamond inheritance scenarios
- Preserves interface order for proper conflict resolution

Fixes the issue where duplicate entries appeared in complex interface
hierarchies while maintaining deterministic behavior for type checking.
@github-actions
Copy link

Teal Playground URL: https://1077--teal-playground-preview.netlify.app

@Frityet
Copy link
Collaborator

Frityet commented Jan 28, 2026

Did you mean to open this PR with this title+description? the changes are unrelated

@Frityet
Copy link
Collaborator

Frityet commented Jan 28, 2026

seems like you accidentally did a PR for #1076 twice 😆

@Nikita-baghela07
Copy link
Contributor Author

oops! sorry

@Nikita-baghela07
Copy link
Contributor Author

I made a mistake.

@hishamhm
Copy link
Member

hishamhm commented Feb 1, 2026

Closing this one since it's the wrong commit.

@hishamhm hishamhm closed this Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants