Comments (4)
I'm not sure that I'd necessarily call this a bug. There does exist a type to provide for t
such that this typechecks: number | boolean
.
from luau.
I don't think there's an immediately obvious way for us to "delay" this change, but if the type of one of the fields is already required to be some particular type (e.g. in that table.insert
example, or if your Position
is cast to Vector3
or annotated Vector3
), then I don't think we should be widening the type to include additional components. It's really only in the case of examples like your original one where I think the behavior is expected. So, there is probably still a bug here, but one more specific than your initial report.
from luau.
I'm not sure that I'd necessarily call this a bug. There does exist a type to provide for
t
such that this typechecks:number | boolean
.
You're right, I don't have label changing permissions though.
My usecase is that the ECS library I use has world:set(id, Position, Vector3.new(0, 0, 0))
, where Position
is ecr.component() :: Vector3
.
The advantage over function overloads is that there's no need to define components upfront, which makes it easy for other libraries to define them.
Maybe if other users have similar usecases it could be worth considering delaying this inference change in strict mode if generic constraints are a long way away?
from luau.
More common example:
--!strict
local t: {string} = {}
table.insert(t, 1)
from luau.
Related Issues (20)
- Unable to Table Assign and Locally Assign Variables at the Same Time While Unpacking HOT 2
- Issue with tabs and the Luau Lexer. HOT 2
- adding @inline tag HOT 1
- [COMPILER OPTIMIZATION] Simplify Conditional Logic Expressions
- "attempt to call a nil value" error message could be improved HOT 1
- Underflow for column count in luau-analyze involving a syntax and return type error in function
- `Luau::findAstAncestryOfPosition` returns short ancestry for global functions with empty blocks
- end keyword doesn't show up in autocomplete suggestions when using a return statement
- Vector XYZW fast path not supported for vectors within immutable globals HOT 1
- Allow removing globals in type definition files
- typeof() not functioning correctly for lightuserdata with a metatable
- Some compiler warnings HOT 9
- Include version in CLI output
- Casting with table indexer doesn't error with new solver
- Type state prevents table key from being changed in new solver
- Reassigning table upvalue errors with new solver
- bad error message for incompatible function types
- Generic function not identifying variadic function parameters correctly
- Create a solution for `__iter` dropping the extra information passed to for loops
- Inference incorrect for intersection types involving unions with new solver
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luau.