Commit Graph

356 Commits

Author SHA1 Message Date
Alexander McCord ba60730e0f
Add documentation on singleton types and tagged unions to typecheck.md. (#440)
Update the typecheck.md page to talk about singleton types and their uses, tagged unions.

As a driveby, improve the documentation on type refinements. And delete the unknown symbols part, this is really dated.

* Update docs/_pages/typecheck.md to fix a typo

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2022-03-31 11:54:06 -07:00
Alan Jeffrey 06bbfd90b5
Fix code sample in March 2022 Recap (#442) 2022-03-31 09:31:06 -05:00
Alan Jeffrey f3ea2f96f7
Recap March 2022 (#439)
* March Recap

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2022-03-30 18:38:55 -05:00
Arseny Kapoulkine af64680a5e
Mark singleton types and unsealed table literals RFCs as implemented (#438) 2022-03-29 16:58:59 -07:00
Andy Friesen 75bccce3db
RFC: Lower Bounds Calculation (#388)
Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
2022-03-29 12:37:14 -07:00
Arseny Kapoulkine 2c339d52c0
Sync to upstream/release/520 (#427) 2022-03-24 15:04:14 -07:00
Arseny Kapoulkine 5e7e462104
Update STATUS.md 2022-03-24 13:10:56 -07:00
Arseny Kapoulkine ab64a097cd
Mark sealed table subtyping RFC as implemented 2022-03-24 13:10:30 -07:00
Arseny Kapoulkine 2335b26ffc
Update library.md
Add documentation for table.clone
2022-03-24 09:31:18 -07:00
Arseny Kapoulkine b8e025311b
Mark table.clone as implemented 2022-03-24 09:29:20 -07:00
Arseny Kapoulkine 5a21c41363
Update STATUS.md 2022-03-24 09:26:42 -07:00
Alexander McCord 7ab76e582c
RFC: Do not implement non-nil postfix `!` operator. (#420)
This is a meta-RFC. I'd like to propose to remove the postfix `!` operator from the language.

I'd like to argue that this operator will eventually become useless and can only be used incorrectly at some point in the future, and that there are likely ways for them to be sound without having to reach for the `!` hammer.

With that, I present these counterarguments:

Shortcoming <span>#</span>1: Refinements does not apply to the block after `return`/`break`/`continue`.

```lua
if not x or not y then return end
-- both x and y are truthy
```

This will be solved by implementing control flow analysis where it'd apply the inverse of the condition leading up to the control transfer statement to the rest of the scope.

Shortcoming <span>#</span>2: Type checker is not aware of the actual state of various locations.

```lua
type Foo = { x: { y: number }? }?
local foo: Foo = { x = { y = 5 } }
print(foo.x.y) -- prints 5 at runtime, type checker warns on this
```

This will be solved by implementing type states where it would inspect the initialization sites as well as assignments to know their actual states. That is, rather than trusting the type annotation `Foo` as the state which gets us far enough, we'd start seeing these type annotations as a subtype constraint for the location `foo`.

---

If there are other use cases not covered in this message, we should talk about that and see if there exists an alternative direction that can solve these use cases soundly.
2022-03-24 08:38:16 -07:00
Alexander McCord 2f15079642
Fold in rationale for making `else` branch mandatory in if-then-else expressions. (#426)
This has been discussed but just didn't get incorporated into the RFC.
2022-03-23 16:53:52 -07:00
Alan Jeffrey 7721955ba5
Prototyping: add semantic subtyping (#424)
Adds subtyping to strict mode.
2022-03-23 15:02:57 -05:00
Arseny Kapoulkine 362428f8b4
Sync to upstream/release/519 (#422) 2022-03-17 17:46:04 -07:00
Luca Salmin 4fdead5e3c
yield from interrupt #287 (#413)
Co-authored-by: luca salmin <luca.salmin@studioevil.com>
2022-03-14 11:43:40 -07:00
Arseny Kapoulkine fe71aff7af
Update library.md 2022-03-14 10:30:49 -07:00
Arseny Kapoulkine a44b7906b6
Sync to upstream/release/518 (#419) 2022-03-11 08:55:02 -08:00
Arseny Kapoulkine dbdf91f3ca
Sync to upstream/release/517 (#408) 2022-03-04 08:36:33 -08:00
Lily Brown 6c923b8802
Prototyping: strings (#390) 2022-03-02 15:26:58 -08:00
Alan Jeffrey c5477d522d
Prototyping strict mode (#399)
* First cut of strict mode

Co-authored-by: Lily Brown <lily@lily.fyi>
2022-03-02 16:02:51 -06:00
vegorov-rbx d277cc2c3b
Luau Recap: February 2022 (#403)
* Luau Recap: February 2022

* Rebuild pages

* Fixed Markdown linter warnings, converted tabs to spaces and added a note on 'select' optimization

* Apply suggestions from code review

Co-authored-by: Alexander McCord <11488393+alexmccord@users.noreply.github.com>

* Added information about new lint

* Update docs/_posts/2022-02-28-luau-recap-february-2022.md

Co-authored-by: Alexander McCord <11488393+alexmccord@users.noreply.github.com>

Co-authored-by: Alexander McCord <11488393+alexmccord@users.noreply.github.com>
2022-03-02 06:27:35 -08:00
Arseny Kapoulkine 898c0501d1
Update STATUS.md
Add table.clone
2022-02-28 14:16:35 -08:00
Arseny Kapoulkine 5e8242aeda
RFC: table.clone (#362) 2022-02-28 14:15:33 -08:00
Arseny Kapoulkine fb11ca00f4
Update README.md
linenoise -> isocline
2022-02-28 10:50:23 -08:00
Arseny Kapoulkine db3a8a2f0f
Update prototyping.yml (#398)
This limits the scope of prototyping action to PRs to prototyping branch to minimize the GHA cost / latency, as cabal install sometimes takes forever
2022-02-24 17:08:54 -08:00
Arseny Kapoulkine c7eca27909
Sync to upstream/release/516 (#397) 2022-02-24 15:53:37 -08:00
Lily Brown 0bd21762ae
Prototype bools and relational operators (#387)
Prototypes booleans and relational operators.

As part of this I removed `FFI/Data/Bool.agda`, because it was getting in the way - we already use `Agda.Builtin.Bool` instead for other cases.
2022-02-24 11:17:46 -08:00
Petri Häkkinen 0bc7c51afc
Lua API: add return types to table getters (#389)
Co-authored-by: Petri Häkkinen <petrih@rmd.remedy.fi>
2022-02-23 10:03:58 -08:00
Lily Brown cd18adc20e
Prototyping: binary operations (#377)
Adds support for binary operations on numbers.
2022-02-22 15:52:56 -08:00
James Napora 1334db600f
Update grammar.md (#379) 2022-02-22 11:24:15 -08:00
Arseny Kapoulkine 3c42b3a013
Revert "Mark singleton types RFC as implemented (#370)" (#378)
This reverts commit 731e197757.
2022-02-19 10:57:29 -08:00
Alan Jeffrey fc33b0c702
Fix evaluation rule for function application (#375) 2022-02-18 16:47:23 -06:00
Alan Jeffrey 0b783d8932
Add Properties.Equality to prototyping (#376) 2022-02-18 16:47:04 -06:00
Lily Brown 7f867ac166
Prototyping: numbers (#368)
Adds number support to the prototype. Binary operators are next.
2022-02-18 11:09:00 -08:00
Arseny Kapoulkine a9bdce6cc0
Rename tests to tests.py (#374) 2022-02-18 10:04:38 -08:00
Arseny Kapoulkine 5b78465059
Sync to upstream/release/514 (#372) 2022-02-17 17:18:01 -08:00
Lily Brown 1ac64af484
Prototyping: Revise CI (#371)
Introduces a test runner with test cases. Also significantly overhauls the GHA configuration.
2022-02-17 17:15:33 -08:00
Arseny Kapoulkine 6aaaafcc8d
Add documentation for upcoming CommentDirective lint (#361) 2022-02-17 16:58:43 -08:00
Alexander McCord 731e197757
Mark singleton types RFC as implemented (#370) 2022-02-17 16:16:31 -08:00
Arseny Kapoulkine e49a0fd4cd
Mark default type parameters RFC as implemented (#369) 2022-02-17 16:14:35 -08:00
Arseny Kapoulkine e541e19f44
Create RFC status tracking document (#363)
This tracks status of all unimplemented RFCs in one central place. Hopefully we won't forget to update this when new RFCs are added!
2022-02-15 18:37:02 -08:00
Lily Brown c8d6dc2758
Revise GHA workflows for prototyping (#367)
Changed the GHA workflows to:
- Not run `build` and `release` workflows for PRs that only affect `prototyping/`
- Run `prototyping` workflow when PRs affect `Analysis/**`, `Ast/**`, or the `luau-ast` source files
2022-02-15 14:24:51 -08:00
Lily Brown f0c9d84461
Prototyping: Parse type annotations (#366)
Parses type annotations from the JSON output of `luau-ast`.
2022-02-15 14:10:43 -08:00
Lily Brown 4b7e06e14f
Emit more information for AstLocals in JSON encoder (#364)
We don't emit type annotations right now for `AstLocal`s in the JSON encoder. This makes it really hard to surface annotations in the Agda implementation. This PR changes it to emit location and type annotations, if present.
2022-02-14 14:14:11 -08:00
Arseny Kapoulkine 7d679b317f
RFC: Generalized iteration (#335)
Co-authored-by: dcope-rbx <91100513+dcope-rbx@users.noreply.github.com>
Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
2022-02-14 10:04:07 -08:00
Alan Jeffrey e0a9bc191a
Prototype: added syntax for optional type annotations (#358) 2022-02-11 19:03:26 -06:00
Alan Jeffrey db90c7da48
Add a typeToString function to the prototype (#354)
* Added Luau.Type.ToString
2022-02-11 14:38:35 -06:00
Arseny Kapoulkine 63d5423bbb
Sync to upstream/release/514 (#357) 2022-02-11 11:02:09 -08:00
Arseny Kapoulkine aecd60371b
Update performance.md (#355)
Document weak table shrinking and paged sweeper
2022-02-11 09:13:27 -08:00
Alan Jeffrey 5187e64f88
Implement a prototype interpreter (#353)
* First cut interpreter
2022-02-09 17:14:29 -06:00
Arseny Kapoulkine abe3f87b48
docs: Add documentation for upcoming MisleadingAndOr lint (#349)
This is going to be part of Luau 0.514
2022-02-09 09:27:01 -08:00
Arseny Kapoulkine ec481695a3
Update library.md (#352)
Clarify the relationship between `typeof` and `newproxy`. As a sandboxing measure, `typeof` only uses `__type` on host-defined userdata.

Fixes #351.
2022-02-09 09:19:50 -08:00
Alan Jeffrey 041838a942
Prototyping a small subset of Luau in Agda (#350)
* First cut reading JSON into an Agda representation of Luau syntax
2022-02-08 18:26:58 -06:00
Michael Savage 324bc4b01d
Add a build option to link with the static CRT (#343)
LUAU_STATIC_CRT CMake option can be set externally (requires CMake 3.15+)
2022-02-07 13:51:57 -08:00
Lily Brown 7ffb5fc4fd
Add Luau.Ast.CLI target (#345)
Adds a `luau-ast` CLI that dumps Luau source to JSON. @asajeffrey and I are planning to use this functionality to construct an Agda model of the Luau type system/operational semantics, to allow formally proving properties of Luau's type systems.
2022-02-07 12:08:43 -08:00
Arseny Kapoulkine e51ff38d19
Sync to upstream/release/513 (#342) 2022-02-04 12:46:08 -08:00
Arseny Kapoulkine d58e70b8c1
Sync to upstream/release/513 (#340) 2022-02-04 08:45:57 -08:00
Andy Friesen c572f6944f
January 2022 recap (#331) 2022-02-01 14:49:55 -08:00
Arseny Kapoulkine 2f989fc049
Sync to upstream/release/512 (#330)
- Improve refinement support for unions, in particular it's now possible to implement tagged unions as a union of tables where individual branches use a string literal type for one of the fields.
- Fix `string.split` type information
- Optimize `select(_, ...)` to run in constant time (~2.7x faster on VariadicSelect benchmark)
- Improve debug line information for multi-line assignments
- Improve compilation of table literals when table keys are constant expressions/variables
- Use forward GC barrier for `setmetatable` which slightly accelerates GC progress
2022-01-27 15:46:05 -08:00
Vlad Marica 4b96f7efc1
luau-analyze: Add support for reading source code from stdin (#325)
Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2022-01-25 08:25:01 -08:00
Arseny Kapoulkine 8fe95c9963
Sync to upstream/release/511 (#324)
- TableOperations lint now includes a warning for table.create(N, {}) (which is likely a mistake since the table is shared by all entries)
- Type checker now type checks #v when v is a union
- Parser now rejects sources that consists of a single unfinished long comment
- Work around significant MSVC 2022 performance regression, bringing it more or less in line with MSVC 2019
- Compiler now predicts array size for newly allocated tables when the table is filled in a short loop
- Small improvements in compilation throughput (~2% faster)
- Implement paged sweeper for GC which improves sweep throughput 2-3x and reduces memory consumption by 8 bytes per object (once it is stabilized we will see additional 8 bytes per object of savings)
- Improve Repl Tab completion
- Repl now supports -i (interactive mode to run code in context of a script's environment) and -On (to control optimization flags)
2022-01-21 09:00:19 -08:00
Shiro 478a3da634
Update copyright years. (#323) 2022-01-20 09:42:49 -08:00
JohnnyMorganz 4e5ff99582
Improve Grammar documentation (#315) 2022-01-20 08:27:19 -08:00
dcope-rbx 49ce5096a4
Fixed a couple spelling mistakes in markdown files. (#316) 2022-01-17 09:44:31 -08:00
Halalaluyafail3 497d625f73
Fix some mistakes in the documentation (#314) 2022-01-14 13:42:49 -08:00
Arseny Kapoulkine 32c39e2162
Sync to upstream/release/510 (#313) 2022-01-14 08:20:09 -08:00
Arseny Kapoulkine b2af550b08
Update grammar.md
Add forgotten quotes around 'type'; reported by @Dionysusnu
2022-01-13 15:23:18 -08:00
Arseny Kapoulkine d6ba106be6
Update compatibility.md
Add a note about function identity
2022-01-12 11:56:46 -08:00
T 'Filtered' C abf9fc2754
Update compatibility.md to split coroutine.close from lua_resetthread (#309)
Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2022-01-12 11:50:25 -08:00
rafa_br34 b7f78f4997
MSVC warning C4244 fixes (#308)
Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2022-01-12 10:05:31 -08:00
Arseny Kapoulkine b7a7b92d12
Update syntax.md
Remove confusing block because it reads as if we *do* support this syntax if you aren't reading carefully.
2022-01-11 13:24:56 -08:00
Arseny Kapoulkine a23b467485
Add turbofish discussion to generic function RFC (#300) 2022-01-07 11:07:36 -08:00
Arseny Kapoulkine 287b46e6a7
Mark bidirectional ascription RFC as implemented (#305) 2022-01-07 11:07:22 -08:00
Arseny Kapoulkine b5e338325b
Mark coroutine.close RFC as implemented (#304) 2022-01-07 08:52:33 -08:00
Arseny Kapoulkine d50b079325
Sync to upstream/release/509 (#303)
- Rework transaction log used for type checking which should result in more robust type checking internals with fewer bugs
- Reduce the amount of memory consumed by type checker on large module graphs
- Type checker now errors on attempts to change the type of imported module fields
- The return type of newproxy is now any (fixes #296)
- Implement new number printing algorithm (Schubfach) which makes tostring() produce precise (round-trippable) and short decimal output up to 10x faster
- Fix lua_Debug::linedefined to point to the line with the function definition instead of the first statement (fixes #265)
- Fix minor bugs in Tab completion in Repl
- Repl now saves/restores command history in ~/.luau_history
2022-01-06 17:46:53 -08:00
Arseny Kapoulkine d323237b6c
Sync to upstream/release/508 (#301)
This version isn't for release because we've skipped some internal
numbers due to year-end schedule changes, but it's better to merge
separately.
2022-01-06 15:26:14 -08:00
Alan Jeffrey 82587bef29
RFC: Fix an unsoundness issue around stripping optional properties (#276)
* Fix an unsoundness issue around stripping optional properties

Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
2022-01-06 12:48:09 -06:00
Arseny Kapoulkine 73b7bcb2da
docs: Move Luau.Web.js fetch to the end of the page
This was moved in the CodeMirror change, but that may break Module setup in the embedded <script> block, so move it back.
2022-01-04 15:04:25 -08:00
Arseny Kapoulkine fa35884e5b
Update library.md
A few small tweaks and fixes.
2021-12-27 13:08:56 -08:00
Arseny Kapoulkine 6203bf6ac5
Update grammar.md
Remove TOC & mark page as wide.
2021-12-27 12:51:23 -08:00
Arseny Kapoulkine 65177c425c
Update grammar.md
This changes the grammar to follow the EBNF rules more rigorously, most significantly quoting all keywords.
2021-12-27 12:48:58 -08:00
Arseny Kapoulkine d079201a6e Fix repeated calls to print() clearing output 2021-12-20 15:44:51 -08:00
Arseny Kapoulkine fedd9a5f78 docs: Fix label syntax 2021-12-20 15:40:38 -08:00
boyned//Kampfkarren 5e7648947b
RFC: Safe navigation operator (#142)
Co-authored-by: Alexander McCord <11488393+alexmccord@users.noreply.github.com>
2021-12-20 15:38:15 -08:00
Arseny Kapoulkine 9e7e779c02
Quality of life improvements to web demo (#297)
- Upgrade CodeMirror to 5.65
- Enable matching paren highlighting via an addon
- Remove extra buttons and replace clear output with a checkbox
- Highlight error line on parsing/execution error
- Change demo layout to wide to increase available width
2021-12-20 15:36:41 -08:00
Pelanyo Kamara 019eeeb853
Add CodeMirror Editor for Web Demo (#228)
Also remove timestamps from output
2021-12-15 09:23:26 -08:00
Arseny Kapoulkine f2e6a8f4a5
Sync to upstream/release/507-pre (#286)
This doesn't contain all changes for 507 yet but we might want to do the
Luau 0.507 release a bit earlier to end the year sooner.

Changes:

- Type ascription (::) now permits casts between related types in both directions, allowing to refine or loosen the type (RFC #56)
- Fix type definition for tonumber to return number? since the input string isn't guaranteed to contain a valid number
- Fix type refinements for field access via []
- Many stability fixes for type checker
- Provide extra information in error messages for type mismatches in more cases
- Improve performance of type checking for large unions when union members are string literals
- Add coverage reporting support to Repl (--coverage command line argument) and lua_getcoverage C API
- Work around code signing issues during Makefile builds on macOS
- Improve performance of truthiness checks in some cases, particularly on Apple M1, resulting in 10-25% perf gains on qsort benchmark depending on the CPU/compiler
- Fix support for little-endian systems; IBM s390x here we go!
2021-12-10 14:05:05 -08:00
Arseny Kapoulkine 88be067c0b
Switch coverage build to checkout@v2 (#285)
Attempt to fix coverage builds by using checkout@v2 instead of v1 which might fix the detacthed HEAD issue.

On the off chance it doesn't, add extra logging around git specifically.
2021-12-09 17:50:29 -08:00
Rerumu 12ef94df5e
Add shebang support (#149)
Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2021-12-09 12:37:48 -08:00
JohnnyMorganz 2e6a2090c3
Add Grammar documentation (#266)
Co-authored-by: Alexander McCord <11488393+alexmccord@users.noreply.github.com>
Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2021-12-08 09:17:28 -08:00
vegorov-rbx 71adace16e
RFC: Amend 'Default type alias type parameters' for type pack parameters (#238)
* Do not allow regular type assignment to a type pack as a default parameter

* With type pack support in type aliases, this second form with an empty list is now supported

* Update rfcs/syntax-default-type-alias-type-parameters.md

Co-authored-by: Alan Jeffrey <403333+asajeffrey@users.noreply.github.com>

* Update syntax-default-type-alias-type-parameters.md

Even more examples

Co-authored-by: Alan Jeffrey <403333+asajeffrey@users.noreply.github.com>
2021-12-08 04:21:47 -08:00
Braeden 2807dcb758
Update JsonEncoder.cpp (#279)
fix JsonEncoder so that AstArray elems are given commas seperating them
2021-12-07 08:14:35 -08:00
Slappy826 3eff1b214e
Fix spelling error of 'ROBLOX' (#277)
* Remove roblox prefix on comment
2021-12-07 08:14:24 -08:00
Arseny Kapoulkine 9488f2379d
Mark bit32.count* RFC as implemented 2021-12-03 11:10:41 -08:00
Arseny Kapoulkine f63ddae898
Enable LuauActivateBeforeExec to activate the fix early (#275)
Fixes #259.
2021-12-03 10:40:31 -08:00
Arseny Kapoulkine 7257f34d89
Update CONTRIBUTING.md
The language around creating RFCs seems a bit redundant now.
2021-12-02 23:08:45 -08:00
Arseny Kapoulkine 32fb6d10a7
Sync to upstream/release/506 (#270)
- Fix some cases where type checking would overflow the native stack
- Improve autocomplete behavior when assigning a partially written function call (not currently exposed through command line tools)
- Improve autocomplete type inference feedback for some expressions where previously the type would not be known
- Improve quantification performance during type checking for large types
- Improve type checking for table literals when the expected type of the table is known because of a type annotation
- Fix type checking errors in cases where required module has errors in the resulting type
- Fix debug line information for multi-line chained call sequences (Add function name information for "attempt to call a nil value" #255)
- lua_newuserdata now takes 2 arguments to match Lua/LuaJIT APIs better; lua_newuserdatatagged should be used if the third argument was non-0.
- lua_ref can no longer be used with LUA_REGISTRYINDEX to prevent mistakes when migrating Lua FFI (Inconsistency with lua_ref #247)
- Fix assertions and possible crashes when executing script code indirectly via metatable dispatch from lua_equal/lua_lessthan/lua_getfield/etc. (Hitting a crash in an assert after lua_equal is called. #259)
- Fix flamegraph scripts to run under Python 2
2021-12-02 22:41:04 -08:00
Arseny Kapoulkine f5ec6df7ba
Update build.yml
Disable continue-on-error for coverage because hiding the error actually makes it difficult to debug now :)
2021-12-02 15:55:06 -08:00
Lily Brown 864221e667
November 2021 Luau recap (#264)
Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2021-12-02 13:22:02 -08:00