Skip to content

Commit

Permalink
When generalizing a union type of function types, generalize their ou…
Browse files Browse the repository at this point in the history
…tput types.
  • Loading branch information
amyjko committed Jun 29, 2024
1 parent 1de29ab commit 4645b16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ Dates are in `YYYY-MM-DD` format and versions are in [semantic versioning](http:
- Better tab symbol to clarify keyboard shortcut and whitespace meaning.
- Improved contrast of delimiters and borders in dark mode.
- Correct typos in tutorial.
- Ensured type errors when a structure definition is given instead of a structure value.
- When generalizing a union type of function types, generalize their output types.
- [#503](https://github.com/wordplaydev/wordplay/issues/503). Prevent infinite loops in parser.
- [#504](https://github.com/wordplaydev/wordplay/issues/504). Account for non-fixed-width characters in caret positioning.
- [#488](https://github.com/wordplaydev/wordplay/issues/488). Added animations off indicator on stage.
- Ensured type errors when a structure definition is given instead of a structure value.
- [#500](https://github.com/wordplaydev/wordplay/issues/500). Improved explanation when there's a space between an evaluation's name and inputs.

## 0.10.1 2024-06-22
Expand Down
7 changes: 6 additions & 1 deletion src/nodes/FunctionType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ export default class FunctionType extends Type {
const outputToCheck = type.output;

if (!(outputToCheck instanceof Type)) return false;
if (!this.output.accepts(outputToCheck, context)) return false;
if (
!this.output
.generalize(context)
.accepts(outputToCheck.generalize(context), context)
)
return false;
// If this function takes fewer than the number of inputs that the given function expects,
// then the given function will not function correctly. But it is okay if the given
// function takes fewer inputs then this function, since it just means it's ignoring some of the inputs.
Expand Down

0 comments on commit 4645b16

Please sign in to comment.