Commit Graph

1109 Commits

Author SHA1 Message Date
Arseny Kapoulkine
61afc5e0dd
Create CNAME 2023-10-16 16:25:47 -07:00
Arseny Kapoulkine
cb59964bda
Delete CNAME 2023-10-16 16:25:28 -07:00
Alexander McCord
6439719cd2
Facelift of the Account OO example. (#578)
When the original version was written, bidirectional type inference
didn't exist, so this new kind of pattern was simply not possible.

Now that it does, we can stop telling users to use the original typeof
workaround.

The only thing that's a bit unfortunate is the cast of `{}` into
`AccountImpl`, but it's a necessary evil for now until we get a few more
big ticket items. When we have that, we can likely kill the cast and
call it redundant.
2023-10-16 16:06:53 -07:00
Micah
7e5643a4ad
RFC: Add bit32.byteswap to support swapping the endianness of integers (#1052)
This function might be of particular use if #739 is accepted, but as it
stands, it still brings a measurable reduction in complexity for
swapping byte order and is measurably faster (around a 50% reduction in
time per operation on my machine), albeit on the order of magnitude of
nanoseconds.
2023-10-16 08:47:23 -07:00
Lily Brown
24fdac4c05
Sync to upstream/release/599 (#1069)
## What's Changed

- Improve POSIX compliance in `CLI/FileUtils.cpp` by @SamuraiCrow #1064
- `AstStat*::hasEnd` is deprecated; use `AstStatBlock::hasEnd` instead
- Added a lint for common misuses of the `#` operator
- Luau now issues deprecated diagnostics for some uses of `getfenv` and
`setfenv`
- Fixed a case where we included a trailing space in some error
stringifications

### Compiler

- Do not do further analysis in O2 on self functions
- Improve detection of invalid repeat..until expressions vs continue

### New Type Solver

- We now cache subtype test results to improve performance
- Improved operator inference mechanics (aka type families)
- Further work towards type states
- Work towards [new non-strict
mode](https://github.com/Roblox/luau/blob/master/rfcs/new-nonstrict.md)
continues

### Native Codegen

- Instruction last use locations should follow the order in which blocks
are lowered
- Add a bonus assertion to IrLoweringA64::tempAddr

---

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
2023-10-13 13:20:12 -07:00
Lily Brown
dc6a75b450 Merge branch 'upstream' into merge 2023-10-13 12:43:34 -07:00
Lily Brown
4d2be9727e Merge remote-tracking branch 'origin/master' into merge 2023-10-13 12:42:29 -07:00
Lily Brown
34efdb3b0a Sync to upstream/release/599 2023-10-13 12:38:31 -07:00
Alex Orlenko
5c94984935
Add lua_getallocf API function (#1068)
This function matches the corresponding Lua 5.1-5.4 function:

[`lua_getallocf`](https://www.lua.org/manual/5.4/manual.html#lua_getallocf)
and [source](https://www.lua.org/source/5.4/lapi.c.html#lua_getallocf)

It would be useful to get/manipulate auxiliary "userdata" pointer that was originally passed to `lua_newstate`.
2023-10-13 08:47:33 -07:00
JohnnyMorganz
1173e415ef
Modify the way line breaks are added when printing unions/intersections (#1047)
Adds an option `compositeTypesSingleLineLimit` to control when
unions/intersections are broken up onto multiple lines when printed.
Simple unions/intersections will remain on one line. Default value is
set to `5`.

I took the liberty to always expand overloaded function intersections on
multiple lines, as I believe they are best viewed that way, even if
theres only 2 functions.

Closes #963
2023-10-12 09:09:47 -07:00
Samuel Crow
984336448c
Improve POSIX compliance in CLI/FileUtils.cpp (#1064)
Some POSIX platforms, such as Haiku and some BSDs, don't supply DT_*
identifiers and the corresponding d_type field in stat. This fixes that
and has been tested to still work on 64-bit Linux as well as 64-bit
Haiku.
2023-10-12 05:46:53 -07:00
Arseny Kapoulkine
3d4e99fc6c rfcs: Update status
String interpolation and table.getn/et al deprecation has been live for
a while.

getfenv/setfenv linter diagnostics is going to ship in the next release,
so preemptively marking this as Implemented as well.
2023-10-11 08:29:25 -07:00
Alan Jeffrey
497dd1bad4
Incorrectness 2024 paper (#1048) 2023-10-09 19:00:31 -05:00
Alan Jeffrey
ffc28da331
RFC for new non-strict mode (#1037) 2023-10-09 18:57:50 -05:00
Andy Friesen
36e0e64715
Sync to upstream/release/598 (#1063)
* Include `windows.h` rather than `Windows.h` to make things compile on
MinGW.
* Custom implementation of timegm/os.time for all platforms
* Disable builtin constant folding when getfenv/setfenv are used
* Fixes https://github.com/Roblox/luau/issues/1042
* Fixes https://github.com/Roblox/luau/issues/1043

New Type Checker

* Initial work toward type states.
* Rework most overloadable operators to use type families.
* Initial work toward our new nonstrict mode.


Native Codegen

* Fix native code generation for dead loops
* Annotate top-level functions as cold
* Slightly smaller/faster x64 Luau calls
* emitInstCall used to not set savedpc itself, but now it does for
consistency with all other implementations
* Implement cmov support for X64
* Fix assertion in luau-compile when module is empty
* Optimize A64 calls at some code size cost
* Inline constant array index offset into the load/store instruction
* Increase x64 spill slots from 5 to 13

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
2023-10-06 12:02:32 -07:00
Andy Friesen
ff9c57255c Turn this down a little temporarily. We'll sort out the root cause later. 2023-10-06 11:39:08 -07:00
Andy Friesen
008b77a09a Merge branch 'upstream' into merge 2023-10-06 10:40:24 -07:00
Andy Friesen
47374ff2a6 Merge branch 'master' into merge 2023-10-06 10:36:16 -07:00
Andy Friesen
22e3d1fa46 Sync to upstream/release/598 2023-10-06 10:31:16 -07:00
Arseny Kapoulkine
225a4a0870
Update compatibility.md (#1059)
Add a note about Lua 5.3 change to semantics of __eq metamethod.

We currently do not plan to implement this as this breaks backwards
compatibility and makes these operators harder to reason about from the
type checking perspective.

Fixes #1051.
2023-10-03 07:39:48 -07:00
Radiant
2a3a030341
Rename Windows.h to windows.h (#1055)
Make it able to compile on MingW

Fixes #873.

Co-authored-by: Radiant <i.like.using.discord@gmail.com>
2023-10-03 06:59:44 -07:00
Alexander McCord
1d0b449181
Sync to upstream/release/597 (#1054)
# New Type Solver

- Implement bidirectional type inference for higher order functions so
that we can provide a more precise type improving the autocomplete's
human factors.
- We seal all tables, so we changed the stringification to make it a
little lighter on users.
- Fixed a case of array-out-of-bound access.
- Type families no longer depends on `TxnLog` and `Unifier`.
- Type refinements now waits until the free types are sufficiently
solved.

# Native Code Generation

- Remove cached slot lookup for `executeSETTABLEKS` function because it
is a fallback in the event of a cache miss, making the cached slot
lookup redundant.
- Optimized repeated array lookups, e.g. `a[3]` in `a[3] = a[3] / 2` is
done once.

# Misc

- On some platforms, it is necessary to use `gmtime_s` with the
arguments reversed to get the current time. You can now define
`DOCTEST_CONFIG_USE_GMTIME_S` to build and run unit tests on those
platforms.

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
2023-09-29 18:13:05 -07:00
Alexander McCord
d42188a2da Merge branch 'heads/upstream' into merge 2023-09-29 17:25:41 -07:00
Alexander McCord
c6b581addc Merge branch 'master' into merge 2023-09-29 17:23:20 -07:00
Alexander McCord
3bfc864280 Sync to upstream/release/597 2023-09-29 17:22:06 -07:00
aaron
16fbfe912c
Sync to upstream/release/596 (#1050)
- Cleaned up `FFlag::FixFindBindingAtFunctionName`,
`FFlag::LuauNormalizeBlockedTypes`, `FFlag::LuauPCallDebuggerFix`
- Added support for break and continue into control flow analysis
- The old type unification engine will now report a more fine-grained
error at times, indicating that type normalization in particular failed

# New Type Solver

- Refactor of Unifier2, the new unification implementation for Luau
- Completed MVP of new unification implementation
- Dramatically simplified overload selection logic
- Type family reduction can now apply sooner to free types that have
been solved
- Subtyping now supports table indexers
- Generalization now replaces bad generics with unknown

# Native Code Generation

- Reduce stack spills caused by FINDUPVAL and STORE_TAG
- Improve Generate SHL/SHR/SAR/rotates with immediate operands in X64
- Removed redundant case re-check in table lookup fallback

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
2023-09-22 12:12:15 -07:00
Aaron Weiss
3882ab1488 Merge branch 'upstream' into merge 2023-09-22 11:12:50 -07:00
Aaron Weiss
d4de6f7502 Merge branch 'master' into merge 2023-09-22 11:12:44 -07:00
Aaron Weiss
81681e2948 Sync to upstream/release/596 2023-09-22 11:10:49 -07:00
Amber Grace
d00e93c82c
Support Control Flow type Refinements for "break" and "continue" statements (#1004)
Fixes: https://github.com/Roblox/luau/issues/913

This PR adds support for type refinements around guard clauses that use
`break` and `continue` statements inside a loop, similar to how guard
clauses with `return` is supported.

I had some free time today, so I figure I'd give a shot at a naïve fix
for this at the very least.

---

## Resulting Change:

Luau now supports type refinements within loops where a `continue` or
`break` guard clause was used.
For example:
```lua
for _, object in objects :: {{value: string?}} do
    if not object.value then
        continue
    end
    local x: string = object.value -- OK; Used to emit "Type 'string?' could not be converted into 'string'"
end
```

---------

Co-authored-by: Alexander McCord <amccord@roblox.com>
2023-09-21 15:28:42 -07:00
Arseny Kapoulkine
309001020a
Update benchmark.yml
Update apt-get cache before installing valgrind as it looks like the default cache got out of date.
2023-09-16 12:21:09 +02:00
Andy Friesen
31a017c5c7
Sync to upstream/release/595 (#1044)
* Rerun clang-format on the code
* Fix the variance on indexer result subtyping. This fixes some issues
with inconsistent error reporting.
* Fix a bug in the normalization logic for intersections of strings

New Type Solver

* New overload selection logic
* Subtype tests now correctly treat a generic as its upper bound within
that generic's scope
* Semantic subtyping for negation types
* Semantic subtyping between strings and compatible table types like
`{lower: (string) -> string}`
* Further work toward finalizing our new subtype test
* Correctly generalize module-scope symbols

Native Codegen

* Lowering statistics for assembly
* Make executable allocation size/limit configurable without a rebuild.
Use `FInt::LuauCodeGenBlockSize` and `FInt::LuauCodeGenMaxTotalSize`.

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
2023-09-15 10:26:59 -07:00
Andy Friesen
c0449320f0 Merge branch 'upstream' into merge 2023-09-15 09:28:12 -07:00
Andy Friesen
55d7a9912d Merge branch 'master' into merge 2023-09-15 09:28:09 -07:00
Andy Friesen
d8b97f4745 Sync to upstream/release/595 2023-09-15 09:27:45 -07:00
Someon1e
a35d3d4588
Demo site: case sensitive highlighting (#1040)
Before:
![image](https://github.com/Roblox/luau/assets/142684596/6a5ec602-9946-48aa-98c7-ddebc404c5dd)

After:
![image](https://github.com/Roblox/luau/assets/142684596/d7a9bf3d-2163-417c-8407-43d65d6eca01)
2023-09-11 09:09:00 -07:00
vegorov-rbx
c7c986b996
Sync to upstream/release/594 (#1036)
* Fixed `Frontend::markDirty` not working on modules that were not
typechecked yet
* Fixed generic variadic function unification succeeding when it should
have reported an error

New Type Solver:
* Implemented semantic subtyping check for function types

Native Code Generation:
* Improved performance of numerical loops with a constant step
* Simplified IR for `bit32.extract` calls extracting first/last bits
* Improved performance of NaN checks
2023-09-07 17:13:49 -07:00
Vyacheslav Egorov
789ece0941 Merge branch 'upstream' into merge 2023-09-07 16:33:17 -07:00
Vyacheslav Egorov
5143f5ecd3 Merge branch 'master' into merge 2023-09-07 16:33:12 -07:00
Vyacheslav Egorov
8e28c240bd Sync to upstream/release/594 2023-09-07 16:28:45 -07:00
Arseny Kapoulkine
bf1fb8f1e4
Update syntax.md (#1035)
Add a note about floor division support.
2023-09-06 18:14:03 -07:00
Arseny Kapoulkine
105f54b233
fix build & test conformance issues on mingw32/gcc and mingw64/clang (#1034)
CLI/Reduce.cpp:
Never worked under MinGW as-is. Add check for MinGW as they're defined.

VM/src/lmem.cpp:
MinGW layout follows more closely MSVC. Checks before were only correct
for 32-bit gcc / clang in non-Windows.

NOTES:
__MINGW32__ is defined on both 32-bit and 64-bit, __MINGW64__ is 64-bit
only. 32-bit MinGW compilers (both Clang & GCC) have a floating point
test error on math.noise, specifically math.lua:258. All other test
cases / unit tests pass modulo stack size issues (so requires optimized build).

---------

Co-authored-by: jdp_ <42700985+jdpatdiscord@users.noreply.github.com>
2023-09-05 10:22:35 -07:00
Arseny Kapoulkine
f0a2e79365
rfcs: Mark floor division RFC as implemented 2023-09-01 14:10:22 -07:00
Arseny Kapoulkine
cb18b53396
Update compatibility.md
Mark floor division operator as implemented
2023-09-01 14:09:18 -07:00
Lily Brown
551a43c424
Sync to upstream/release/593 (#1024)
- Updated Roblox copyright to 2023
- Floor division operator `//` (implements #832)
- Autocomplete now shows `end` within `do` blocks
- Restore BraceType when using `Lexer::lookahead` (fixes #1019)

# New typechecker

- Subtyping tests between metatables and tables
- Subtyping tests between string singletons and tables
- Subtyping tests for class types

# Native codegen

- Fixed macOS test failure (wrong spill restore offset)
- Fixed clobbering of non-volatile xmm registers on Windows
- Fixed wrong storage location of SSA reg spills
- Implemented A64 support for add/sub extended
- Eliminated zextReg from A64 lowering
- Remove identical table slot lookups
- Propagate values from predecessor into the linear block
- Disabled reuse slot optimization
- Keep `LuaNode::val` check for nil when optimizing `CHECK_SLOT_MATCH`
- Implemented IR translation of `table.insert` builtin
- Fixed mmap error handling on macOS/Linux

# Tooling

- Used `|` as a column separator instead of `+` in `bench.py`
- Added a `table.sort` micro-benchmark
- Switched `libprotobuf-mutator` to a less problematic version
2023-09-01 10:58:27 -07:00
Lily Brown
09fdb4cfbd Merge branch 'upstream' into merge 2023-09-01 10:15:30 -07:00
Lily Brown
a2df5951d4 Merge branch 'master' into merge 2023-09-01 09:40:20 -07:00
Lily Brown
397dbb1188 Sync to upstream/release/593 2023-09-01 09:38:53 -07:00
vegorov-rbx
ce9414cb98
Sync to upstream/release/592 (#1018)
* AST queries at position where function name is will now return
AstExprLocal
* Lexer performance has been slightly improved
* Fixed incorrect string singleton autocomplete suggestions (fixes #858)
* Improved parsing error messages
* Fixed crash on null pointer access in unification (fixes #1017)
* Native code support is enabled by default and `native=1`
(make)/`LUAU_NATIVE` (CMake)/`-DLUA_CUSTOM_EXECUTION` configuration is
no longer required

New typechecker:
* New subtyping check can now handle generic functions and tables
(including those that contain cycles)

Native code generation:
* Loops with non-numeric parameters are now handled by VM to streamline
native code
* Array size check can be optimized away in SETLIST
* On failure, CodeGen::compile returns a reason
* Fixed clobbering of non-volatile xmm registers on Windows
2023-08-25 10:23:55 -07:00
Vyacheslav Egorov
51d4d18ec0 Late fixes 2023-08-25 18:46:28 +03:00