Skip to content

fix: subtype check for literal and union types#1288

Merged
lars-reimann merged 1 commit intomainfrom
type-checking-for-literal-and-union-types
Dec 28, 2024
Merged

fix: subtype check for literal and union types#1288
lars-reimann merged 1 commit intomainfrom
type-checking-for-literal-and-union-types

Conversation

@lars-reimann
Copy link
Member

@lars-reimann lars-reimann commented Dec 28, 2024

Summary of Changes

Previously, the type checker incorrectly showed an error in the following program at the call marked with the arrow:

package bug

@Pure fun bug1(p: union<Int, String>)
@Pure fun bug2() -> r: literal<1, "">

pipeline bug3 {
    val a = bug2();
    bug1(a); // <----
}

This was caused because the quantifiers when comparing literal and union types were in the wrong order:

  • We checked whether there was an option in the union type that all constants of the literal type could be assigned to.
  • Now we check whether, for each constant of the literal type, there is an option in the union type they could be assigned to.

@github-actions
Copy link

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ REPOSITORY git_diff yes no 0.14s
✅ TYPESCRIPT eslint 2 0 0 4.5s
✅ TYPESCRIPT prettier 2 0 0 0.95s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@codecov
Copy link

codecov bot commented Dec 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.72%. Comparing base (3880bfe) to head (112cb9b).
Report is 42 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1288   +/-   ##
=======================================
  Coverage   99.72%   99.72%           
=======================================
  Files         114      114           
  Lines       12801    12805    +4     
  Branches     4205     4208    +3     
=======================================
+ Hits        12766    12770    +4     
  Misses         35       35           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lars-reimann lars-reimann merged commit 911881c into main Dec 28, 2024
7 checks passed
@lars-reimann lars-reimann deleted the type-checking-for-literal-and-union-types branch December 28, 2024 14:07
lars-reimann pushed a commit that referenced this pull request Jan 4, 2025
## [0.23.0](v0.22.0...v0.23.0) (2025-01-04)

### Features

* categorize API elements ([#1285](#1285)) ([3275900](3275900)), closes [#1243](#1243)
* optional error messages for constraints ([#1275](#1275)) ([fce761c](fce761c)), closes [#1082](#1082)
* prevent editing built-in stubs ([#1282](#1282)) ([d02c30a](d02c30a))
* show placeholders in outline ([#1286](#1286)) ([3880bfe](3880bfe))

### Bug Fixes

* subtype check for literal and union types ([#1288](#1288)) ([911881c](911881c))
* subtype check for literal and union types (part 2) ([#1289](#1289)) ([56284cf](56284cf))
* type inference for lambdas and their parameters ([#1304](#1304)) ([a9e070f](a9e070f))
@lars-reimann
Copy link
Member Author

🎉 This PR is included in version 0.23.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant