Skip to content

feat: optional error messages for constraints#1275

Merged
lars-reimann merged 6 commits intomainfrom
1082-optional-error-messages-for-constraints
Nov 29, 2024
Merged

feat: optional error messages for constraints#1275
lars-reimann merged 6 commits intomainfrom
1082-optional-error-messages-for-constraints

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
@github-actions
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

@codecov
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 37 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
@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