Skip to content

Implement type negation syntax#2196

Draft
PhoenixWhitefire wants to merge 48 commits into
luau-lang:masterfrom
PhoenixWhitefire:type-negation-syntax
Draft

Implement type negation syntax#2196
PhoenixWhitefire wants to merge 48 commits into
luau-lang:masterfrom
PhoenixWhitefire:type-negation-syntax

Conversation

@PhoenixWhitefire

@PhoenixWhitefire PhoenixWhitefire commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Implements syntax as per negation-types RFC (luau-lang/rfcs#29)

  • Adds flags LuauTypeNegationSyntax, LuauTypeNegationSupport
  • Adds 1 parser test and 13 inference tests (some copied and changed from using a type function)
  • Adds InvalidNegation error
local x: ~number = 5
-- TypeError: Expected this to be '~number', but got 'number'; 
-- the negation `~number`, and `number` is not a subtype of `~number`

local y: ~{ x: number }
-- TypeError: It is not possible to negate the type `{ x: number }` as, being a table type, it is non-testable.

@PhoenixWhitefire

Copy link
Copy Markdown
Contributor Author

Just need to convert it to use a negate internal type function and should be good

Comment thread Analysis/include/Luau/Error.h Outdated
Comment thread Analysis/src/Error.cpp Outdated
@PhoenixWhitefire

PhoenixWhitefire commented Jan 17, 2026

Copy link
Copy Markdown
Contributor Author

Have updated it to use an internal negate type function as per RFC

@PhoenixWhitefire
PhoenixWhitefire marked this pull request as ready for review January 18, 2026 13:52
Comment thread tests/TypeInfer.negations.test.cpp Outdated
Comment thread Analysis/src/ConstraintGenerator.cpp Outdated
Comment thread Analysis/src/ConstraintGenerator.cpp Outdated
Comment thread tests/TypeInfer.negations.test.cpp Outdated
Comment thread tests/TypeInfer.negations.test.cpp Outdated
@PhoenixWhitefire
PhoenixWhitefire marked this pull request as draft February 5, 2026 10:56
@PhoenixWhitefire

PhoenixWhitefire commented Feb 13, 2026

Copy link
Copy Markdown
Contributor Author

A PR has been made by Alex, so I will be closing this under the presumption that their implementation will be better.

#2242

@PhoenixWhitefire
PhoenixWhitefire marked this pull request as ready for review June 4, 2026 06:16
@PhoenixWhitefire

Copy link
Copy Markdown
Contributor Author

stole more code from alex

@PhoenixWhitefire
PhoenixWhitefire marked this pull request as draft July 12, 2026 12:49
@PhoenixWhitefire

Copy link
Copy Markdown
Contributor Author

draft until #2543 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants