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.
* 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>
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.
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
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.
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.
- 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