Skip to content

Negation type#2242

Draft
alexmccord wants to merge 7 commits intoluau-lang:masterfrom
alexmccord:why-so-negative
Draft

Negation type#2242
alexmccord wants to merge 7 commits intoluau-lang:masterfrom
alexmccord:why-so-negative

Conversation

@alexmccord
Copy link
Contributor

Mostly there, but still have a few things I need to take care of.

  1. If the ordering is antitone (any odd number of negations: ~T/~~~T/~~~~~T/etc), produce an error. They're all Russell's paradox in disguise, so we have no fixed point.
  2. Otherwise, find the least/greatest fixed point depending on the monotone function (union/intersection), as per Knaster-Tarski theorem.

)");

LUAU_REQUIRE_NO_ERRORS(result);
// LUAU_REQUIRE_ERROR_COUNT(1, result);
Copy link
Member

Choose a reason for hiding this comment

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

My guess is the missing error reporting here is why this is still a draft, but we obviously need to report an error for these cases.

Copy link
Contributor Author

@alexmccord alexmccord Feb 13, 2026

Choose a reason for hiding this comment

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

Yeah. This is where it gets interesting, because TypeFunctionReductionResult::error only works if you have user-defined type functions, but since negation types can be used on type parameters, you can't just do it syntactically, you need to produce errors on instantiations. For this reason I decided to punt on it for a moment and have a think, because it's teetering on kind systems.

Co-authored-by: ariel <aweiss@hey.com>
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.

3 participants