Commit Graph

1211 Commits

Author SHA1 Message Date
Vighnesh
8c4f9070c5 Merge branch 'master' into merge 2024-08-16 10:14:44 -07:00
Ketasaja
1788e237fc
Make os.clock use clock_gettime on FreeBSD (#1364) 2024-08-14 08:31:59 -07:00
Petri Häkkinen
9dc299ecaf
Fix size of userdata metatable array (#1366)
Fix udatamt array to use the correct limit for tagged userdata.
2024-08-14 06:00:21 -07:00
Andy Friesen
bfad1fa777
Sync to upstream/release/638 (#1360)
New Solver

* Fix some type inference issues surrounding updates to upvalues eg

```luau
local x = 0

function f()
    x = x + 1
end
```

* User-defined type function progress
* Bugfixes for normalization of negated class types. eg `SomeClass &
(class & ~SomeClass)`
* Fixes to subtyping between tables and the top `table` type.

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Junseo Yoo <jyoo@roblox.com>
2024-08-09 10:18:20 -07:00
Andy Friesen
c229a9e598 Merge branch 'upstream' into merge 2024-08-09 09:46:45 -07:00
Andy Friesen
057bdf3556 Merge branch 'master' into merge 2024-08-09 09:46:41 -07:00
Andy Friesen
8a99f25381 Sync to upstream/release/638 2024-08-09 09:46:26 -07:00
Junseo Yoo
ce8495a69e
Sync to upstream/release/637 (#1354)
# What's Changed?

- Code refactoring with a new clang-format
- More bug fixes / test case fixes in the new solver

## New Solver

- More precise telemetry collection of `any` types
- Simplification of two completely disjoint tables combines them into a
single table that inherits all properties / indexers
- Refining a `never & <anything>` does not produce type family types nor
constraints
- Silence "inference failed to complete" error when it is the only error
reported

---
### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Dibri Nsofor <dnsofor@roblox.com>
Co-authored-by: Jeremy Yoo <jyoo@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-08-02 07:30:04 -07:00
Junseo Yoo
1adbd45b20 Merge branch 'upstream' into merge 2024-08-01 16:26:06 -07:00
Junseo Yoo
5b401524f5 Merge branch 'master' into merge 2024-08-01 16:26:00 -07:00
Junseo Yoo
fad8aaf0ab Sync to upstream/release/637 2024-08-01 16:25:12 -07:00
ds-sloth
58f8c24ddb
BytecodeBuilder.cpp: fix invalid assumption that int32_t aliases int (#1347)
I found that Luau failed to build on the devkitPro toolchain for 3DS.

This target uses an ILP32 model, and `int32_t` is an alias of `long`.
`BytecodeBuilder.cpp` includes a line where an `int` is passed by
reference to a function expecting an `int32_t`.
2024-07-26 14:34:58 -07:00
Junseo Yoo
5e0779fd57
Sync to upstream/release/636 (#1346)
# What's Changed?

- Telemetry support for usage of any type in old/new solver
- Bug fixes and flag removals with the new solver

## New Solver

- Fixed constraint ordering bug to infer types more accurately
- Improved inferring a call to `setmetatable()`

## VM

- Restored global metatable lookup for `typeof` on lightuserdata to fix
unintentional API change (Fixes #1335)

---
### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Dibri Nsofor <dnsofor@roblox.com>
Co-authored-by: Jeremy Yoo <jyoo@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-07-26 10:47:49 -07:00
Junseo Yoo
28c48cf460 Skip StudioReportLuauAny flag in tests 2024-07-26 10:46:07 -07:00
Junseo Yoo
bb7d5cf6c8 StudioReportLuauAny added to ExperimentalFlags 2024-07-26 10:22:34 -07:00
Junseo Yoo
48c0e9f625 Merge branch 'upstream' into merge 2024-07-25 17:24:36 -07:00
Junseo Yoo
fab4eec97b Merge branch 'master' into merge 2024-07-25 17:11:00 -07:00
Junseo Yoo
7dd10b16dc Sync to upstream/release/636 2024-07-25 17:10:42 -07:00
vegorov-rbx
a80abdb9b3
Add new solver pass to the coverage build (#1341) 2024-07-23 08:08:32 -07:00
Kalrnlo
39d2c295e7
Fix misspelling in parser.cpp (#1330)
Fixes the mispelling of instead
2024-07-22 15:36:17 -07:00
Vighnesh-V
a7299c3f0f
Sync to upstream/release/635 (#1337)
# What's Changed?

- Bugfixes in the new solver

## New Solver
- Equality graphs(E-Graphs) data structures were added
- Refactored even more instances of "type family" with "type function"
- `table.insert` no longer spuriously warns while selecting an overload
for reasonable arguments.
- Add time tracing for the new solver
- Miscellaneous fixes to unit tests

---
### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Jeremy Yoo <jyoo@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Junseo Yoo <jyoo@roblox.com>
2024-07-19 11:20:47 -07:00
Vighnesh
ac97a491c1 Merge branch 'upstream' into merge 2024-07-19 10:40:51 -07:00
Vighnesh
79966e94a7 Merge branch 'master' into merge 2024-07-19 10:24:28 -07:00
Vighnesh
6fd26c55ff Sync to upstream/release/635 2024-07-19 10:21:40 -07:00
birds3345
2874ca9e86
Optimizations for UnionFind (#1334)
Implements ranks & path compression for union find.

---------

Co-authored-by: Alexander McCord <11488393+alexmccord@users.noreply.github.com>
2024-07-17 16:19:57 -07:00
JohnnyMorganz
623e1e30db
Store definitionLocation in ClassType (#1313)
Store the location of an `AstStatDeclareClass` in the `ClassType` as
`definitionLocation`.

This is useful for documentation comments and Go To Definition on a
class type

https://github.com/luau-lang/luau/issues/1137#issuecomment-2212413633
2024-07-17 07:43:31 -07:00
Alexander McCord
4f917420d7
Fix incorrect comment in sources of Luau.EqSat. (#1333) 2024-07-16 10:51:51 -07:00
Alexander McCord
e1bf6289c7
Equality graphs (#1285)
Working towards a full e-graph implementation as described by the [egg
paper](https://arxiv.org/pdf/2004.03082).

The type system has a couple of places where e-graphs would've been
useful and solved some classes of problems trivially. For example:

1. Normalization and simplification cannot handle cyclic types due to
the nature of their implementation.
2. Normalization can't tell when two tables or functions are equivalent,
but simplification theoretically can albeit not implemented.
3. Normalization requires deep normalization for inhabitance check,
whereas simplification would've returned the `never` type itself
indicating uninhabited.
4. Simplification requires constraint ordering to have perfect timing to
simplify.
5. Adding a rewrite rule requires implementing it twice, once in
simplification and once again in normalization with completely different
code design making it hard to verify that their behavior is materially
equivalent.
6. In cases where we must cache for performance, two different types
that are isomorphic have different cache entries resulting in cache
misses.
7. Type family reduction can handle cyclic type families, but only if
the cycle is not obscured by a different type family instance. (`t1
where t1 = union<number, add<t1, number>>` is irreducible)

I think we're getting the point!

---

Currently the implementation is missing a few features that makes
e-graphs actually useful. Those will be coming in a future PR.

1. Pattern matching,
6. Applying rewrites,
7. Rewrite until saturation, and
8. Extracting the best e-node according to some cost function.
2024-07-16 10:35:20 -07:00
Junseo Yoo
b6b74b4425
Sync to upstream/release/634 (#1325)
# What's Changed?

- Performance improvement in the old solver
- Bugfixes in the new solver

## Old Solver

- Mark types that do not need instantiation when being exported to
prevent unnecessary work from being done

## New Solver

- Refactored instances of "type family" with "type function"
- Index-out-of-bounds bug fix in the resolution resolver
- Subtyping reasonings are merged only if all failed

---
### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-07-12 10:03:36 -07:00
Junseo Yoo
5a23350108 Merge branch 'upstream' into merge 2024-07-11 16:15:04 -07:00
Junseo Yoo
a62f6619c2 Merge branch 'master' into merge 2024-07-11 15:18:21 -07:00
Junseo Yoo
1c1476fa2d Sync to upstream/release/634 2024-07-11 15:13:45 -07:00
mttsner
6bfc38e61a
Fix incorrect comment in Bytecode.h (#1315)
The description of SUBRK/DIVRK is out of sync with the VM code.

Comment:
```cpp
// SUBRK, DIVRK: compute arithmetic operation between the constant and a source register and put the result into target register
// A: target register
// B: source register
// C: constant table index (0..255); must refer to a number
LOP_SUBRK,
LOP_DIVRK,
```
VM snippet:
```cpp
VM_CASE(LOP_DIVRK)
    {
        Instruction insn = *pc++;
        StkId ra = VM_REG(LUAU_INSN_A(insn));
        TValue* kv = VM_KV(LUAU_INSN_B(insn));
        StkId rc = VM_REG(LUAU_INSN_C(insn));
        ...
```
2024-07-09 16:00:17 -07:00
JohnnyMorganz
f5a2c5d55e
Keep commentLocations on SourceModule for definition files (#1314)
Right now, the commentLocations are not transferred over to the
SourceModule for definition files, like they are for normal source
modules. This means we lose out on finding documentation comments. We
add that in here

https://github.com/luau-lang/luau/issues/1137#issuecomment-2212413633
2024-07-09 15:28:21 -07:00
Vighnesh-V
a7be4fcc54
Sync to upstream/release/633 (#1318)
# What's Changed?

- Mostly stability and bugfixes with the new solver.

## New Solver

- Typechecking with the new solver should respect the no-check hot
comment.
- Record type alias locations and property locations of table
assignments
- Maintain location information for exported table types
- Stability fixes for normalization
- Report internal constraint solver errors.

---
### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-07-08 14:57:06 -07:00
Vighnesh
bc1bead287 Merge branch 'upstream' into merge 2024-07-08 13:28:05 -07:00
Vighnesh
2010be1575 Merge branch 'master' into merge 2024-07-08 13:27:58 -07:00
Vighnesh
cfcb545b39 Sync to upstream/release/633 2024-07-08 13:22:11 -07:00
aaron
0d2688844a
Sync to upstream/release/632 (#1307)
# What's Changed?

- Fix #1137 by appropriately retaining additional metadata from
definition files throughout the type system.
- Improve Frontend for LSPs by appropriately allowing the cancellation
of typechecking while running its destructor.

## New Solver

- Added support for the `rawget` type function.
- Reduced overall static memory usage of builtin type functions.
- Fixed a crash where visitors could mutate a union or intersection type
and fail to invalidate iteration over them in doing so.
- Revised autocomplete functionality to not rely on a separate run of
the type solver when using the new solver.
- Implemented a more relaxed semantic rule for casting.
- Fixed some smaller crashes in the new solver.

## Native Code Generation

- Add additional codegen specialization for `math.sign`
- Cleaned up a large number of outstanding fflags in the code.

### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: James McNellis <jmcnellis@roblox.com>
Co-authored-by: Jeremy Yoo <jyoo@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-06-28 17:34:49 -07:00
Aaron Weiss
da48758d04 Merge branch 'upstream' into merge 2024-06-28 17:08:27 -07:00
Aaron Weiss
c5a2a4b68f Merge branch 'master' into merge 2024-06-28 17:08:21 -07:00
Aaron Weiss
240a9d8f7f Sync to upstream/release/632 2024-06-28 17:07:35 -07:00
vegorov-rbx
caee04d82d
Sync to upstream/release/631 (#1299)
### What's new

* Added lint warning for using redundant `@native` attributes on
functions inside a `--!native` module
* Improved typechecking speed in old solver for modules with large types

### New Solver

* Fixed the length type function sealing the table prematurely
* Fixed crashes caused by general table indexing expressions

### VM

* Added support for a specialized 3-argument fast-call instruction to
improve performance of `vector` constructor, `buffer` writes and a few
`bit32` methods

---

### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
2024-06-20 16:37:55 -07:00
Vyacheslav Egorov
dafb44dd3d Merge branch 'upstream' into merge 2024-06-21 01:24:20 +03:00
Vyacheslav Egorov
5d2e3de4b0 Merge branch 'master' into merge 2024-06-21 01:24:15 +03:00
Vyacheslav Egorov
816cb1d1c4 Sync to upstream/release/631 2024-06-21 01:23:57 +03:00
Vighnesh-V
7d4033071a
Sync to upstream/release/630 (#1295)
### What's new

* A bug in exception handling in GCC(11/12/13) on MacOS prevents our
test suite from running.
* Parser now supports leading `|` or `&` when declaring `Union` and
`Intersection` types (#1286)
* We now support parsing of attributes on functions as described in the
[rfc](https://github.com/luau-lang/rfcs/pull/30)
* With this change, expressions such as `local x = @native function(x)
    return x+1 end` and `f(@native function(x) return x+1 end)` are now
    valid.
* Added support for `@native` attribute - we can now force native
compilation of individual functions if the `@native` attribute is
specified before the `function` keyword (works for lambdas too).

### New Solver

* Many fixes in the new solver for crashes and instability
* Refinements now use simplification and not normalization in a specific
case of two tables
* Assume that compound assignments do not change the type of the
left-side operand
* Fix error that prevented Class Methods from being overloaded

### VM

* Updated description of Garbage Collector invariant

---
### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-06-14 13:21:20 -07:00
Vighnesh
1ba3e5fd7b correct the flag name 2024-06-14 11:23:44 -07:00
Vighnesh
2a1359dad0 Merge branch 'upstream' into merge 2024-06-14 09:40:49 -07:00
Vighnesh
91790efb8d Merge branch 'master' into merge 2024-06-14 09:40:20 -07:00