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

Add eager inference annotation for polymorphic types #106

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
213ec9f
Create monomorphic-type-bindings-for-generics.md
Ukendio Mar 5, 2025
cb82f7a
Update monomorphic-type-bindings-for-generics.md
Ukendio Mar 5, 2025
bf354a1
Update and rename monomorphic-type-bindings-for-generics.md to eager-…
Ukendio Mar 5, 2025
8f1c0d9
Update "Function-parameter-bindings" alternative
hardlyardi Mar 5, 2025
8a24f5b
Add .md extension
hardlyardi Mar 5, 2025
9df20a0
Update eager-inference-annotations-for-polymorphic-types.md
Ukendio Mar 5, 2025
e25643f
change per-function-parameter to per-argument
hardlyardi Mar 6, 2025
1943be7
change "generic" to "polymorphic type" in a few places
hardlyardi Mar 7, 2025
1d36401
Punctuation Fixes
hardlyardi Mar 7, 2025
1c8d217
change "inference behavior" to "instantiation behavior" in alternative
hardlyardi Mar 7, 2025
2ed0187
Update eager-inference-annotations-for-polymorphic-types.md
hardlyardi Mar 7, 2025
b7c2800
add line break
hardlyardi Mar 7, 2025
b47e000
Update wording in summary
hardlyardi Mar 7, 2025
29384af
add comma
hardlyardi Mar 7, 2025
f5c5609
Update eager-inference-annotations-for-polymorphic-types.md
Ukendio Mar 7, 2025
b995140
remove redundant "union behavior"
hardlyardi Mar 7, 2025
5308d81
Update eager-inference-annotations-for-polymorphic-types.md
Ukendio Mar 7, 2025
c9328c7
Update eager-inference-annotations-for-polymorphic-types.md
Ukendio Mar 7, 2025
27d8c66
changes to alternatives
hardlyardi Mar 7, 2025
cbc02bd
general changes + rephrasing
hardlyardi Mar 7, 2025
9fa24be
add single char monospace
hardlyardi Mar 7, 2025
96f8aaa
Update eager-inference-annotations-for-polymorphic-types.md
Ukendio Mar 7, 2025
b83c473
small consistency/grammar change
hardlyardi Mar 7, 2025
1fee95b
add return statement
hardlyardi Mar 7, 2025
458dcb6
fix spelling :(
hardlyardi Mar 7, 2025
8bb92ba
Amend per-function-bindings to per-usage-bindings
hardlyardi Mar 7, 2025
7d20d52
separate noinfer alternative for clarity
hardlyardi Mar 7, 2025
2463447
Update eager-inference-annotations-for-polymorphic-types.md
hardlyardi Mar 7, 2025
6264249
Update eager-inference-annotations-for-polymorphic-types.md
Ukendio Mar 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix spelling :(
hardlyardi authored Mar 7, 2025
commit 458dcb645fdf9fb097613105d5f075fb59e31716
2 changes: 1 addition & 1 deletion docs/eager-inference-annotations-for-polymorphic-types.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ The RFC introduces a feature to annotate polymorphic function types to express t

## Motivation

The purpose of this feature is to dvelop syntax to prevent polymorphic types from widening into (e.g., number | string) when a function is implicitly instantiated with different argument types. E.g., `test(1, "a")`. In the following code, Luau's current solver infers `T` to be of a union type:
The purpose of this feature is to develop syntax to prevent polymorphic types from widening into (e.g., number | string) when a function is implicitly instantiated with different argument types. E.g., `test(1, "a")`. In the following code, Luau's current solver infers `T` to be of a union type:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "Luau's current solver?"

We have two products right now, Luau's Type Solver and Luau's New Type Solver. "type solver" is really a brand name coined by @andyfriesen, not something external folks necessarily recognize. Could also reasonably describe it as Luau's V2 type inference engine or something of that sort, honestly not entirely sure how we want to deal with the language around the two type inference systems in RFCs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I considered this while editing the motivation paragraph, but was unsure if "type inference engine V2" was even the correct terminology to use. For now I'll switch the terminology there to "Luau's Type Inference Engine V2"?


```luau
function test<T>(a: T, b: T): T