Track type spans in ToStringResult to support decomposition#2163
Merged
vegorov-rbx merged 2 commits intoluau-lang:masterfrom Jan 15, 2026
Merged
Track type spans in ToStringResult to support decomposition#2163vegorov-rbx merged 2 commits intoluau-lang:masterfrom
vegorov-rbx merged 2 commits intoluau-lang:masterfrom
Conversation
WheretIB
reviewed
Dec 26, 2025
andyfriesen
added a commit
that referenced
this pull request
Jan 23, 2026
Hey everyone! We've been hard at work fixing bugs and improving native codegen. Enjoy! # Analysis * Rename the class tag to extern in type functions * Fix #2204 * Rework type unification in terms of subtyping. This uses the new solver's understanding of subtyping to drive unification for some internal callsites. This is a broad change that should result in more consistent inference. For example: ```luau local function sum<T>(x: T, y: T, z: (T, T) -> T) return z(x, y) end local function sumrec(f: typeof(sum)) return sum(2, 3, function<X>(g: X, h: X): add<X, X> return g + h end) end -- Prior we would claim that `b` is of type `add<X, X> | number`: not good! -- We now correctly claim that it is of type `number` thanks to bug fixes -- made to subtyping that did not make their way to the unifier. local b = sumrec(sum) ``` # Native Codegen * Improve vector handling in binary operations * Fix missed optimization causing an assertion failure * Propagate loads of STORE_VECTOR components produced by UINT_TO_FLOAT * Constant-fold new operand of CHECK_BUFFER_LEN * For register load-store propagation, use the second operand only for LOAD_FLOAT * TValue store cannot be removed when it's partially over-written * Rework equality and ordering comparisons to fix issues and be more type aware * Migrate Luau NCG IrInst operands representation to SmallVector # Runtime * Fix 64-bit countrz to build on 32 bit Windows. * Remap Luau local debug and type information after performing jump expansion * Add support for building Luau as a shared library * Luau should be able to make fastcalls even if library name is obscured by a local polyfill # OSS Contributions * #2163 * #2167 # Internal Contributors Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Ilya Rezvov <irezvov@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com> Co-authored-by: Alexander Youngblood <ayoungblood@roblox.com> Co-authored-by: Menarul Alam <malam@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Vighnesh <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@roblox.com> Co-authored-by: Ilya Rezvov <irezvov@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a new
typeSpansfield on ToStringResult to record which TypeId produced parts of the substring in the stringified output. This enables tooling to decompose the result and map positions in the type string back to their source types, powering features such as Go-To-Definition in Inlay Hints.typeSpansis a vector of{startOffset, endOffset, typeId}within the string. We only populate spans for named types, i.e. extern types and named table / metatable types. The rest of the type kinds are ignored.Special attention needs to be given for
UnionTypeandIntersectionType. When stringifying these compound types, it works by resetting thestate.result.nameto an empty string before stringifying the part, then recomposing all the parts back to the full string. This can also include a sorting step.We need to correct the typeSpans during this approach. We introduce a new
ElementResultthat stores the resulting string and set of spans for each part. Then when reconstructing, we offset each span by the current size ofstate.result.name.These changes are gated behind the FFlag
LuauToStringDecompositionCloses #1591