Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optional error messages for constraints #1275

Merged
merged 6 commits into from
Nov 29, 2024

Conversation

lars-reimann
Copy link
Member

@lars-reimann lars-reimann commented Nov 29, 2024

Closes #1082

Summary of Changes

Constraints can now have custom error messages. These can be static strings or template strings that references constant parameter, e.g. in

@Pure fun f(
    const p1: Int,
    const p2: Int = -2,
) where {
    p1 >= 0 else "This parameter must be non-negative.",
    p2 > p1 else "p2 must be greater than p1, but p2 was {{ p2 }} and p1 was {{ p1 }}.",
}

@lars-reimann lars-reimann linked an issue Nov 29, 2024 that may be closed by this pull request
Copy link

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ JSON jsonlint 2 0 0.2s
✅ JSON npm-package-json-lint yes no 0.6s
✅ JSON prettier 2 0 0 0.9s
✅ JSON v8r 2 0 2.13s
✅ PYTHON black 1 0 0 0.91s
✅ PYTHON mypy 1 0 2.39s
✅ PYTHON ruff 1 0 0 0.26s
✅ REPOSITORY git_diff yes no 0.15s
✅ TYPESCRIPT eslint 4 0 0 5.91s
✅ TYPESCRIPT prettier 4 0 0 1.08s

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

Copy link

codecov bot commented Nov 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.75%. Comparing base (1a3bf80) to head (750eb76).
Report is 25 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1275   +/-   ##
=======================================
  Coverage   99.75%   99.75%           
=======================================
  Files         113      114    +1     
  Lines       12751    12790   +39     
  Branches     4190     4203   +13     
=======================================
+ Hits        12720    12759   +39     
  Misses         31       31           

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

@lars-reimann lars-reimann merged commit fce761c into main Nov 29, 2024
7 checks passed
@lars-reimann lars-reimann deleted the 1082-optional-error-messages-for-constraints branch November 29, 2024 10:28
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.

Optional error messages for constraints
1 participant