Comments (3)
The compiler does know that javascript has classes, but it doesn't know what to do with them, so it throws an error.
The main problem with allowing "implicit" formatting is that the compiler can't trust the types of variables, except those that are constant, because you can cast a value to any
and then cast it into some other type.
Besides that, I still need to figure out what to do about allowing mutable objects and allowing objects to be assigned to mutable variables (#212 is a possible solution, but it comes with its own drawbacks).
from mlogjs.
Ha, yes, the message is so clear. There is no handler for classes, I should have guess myself ! grr
Doesn't the compiler can trust variables or argument ' types when the type is declared
function foo(a : Point, b : Square)
You can close this issue after (if) you answer.
Thanks
from mlogjs.
Doesn't the compiler can trust variables or argument ' types when the type is declared
function foo(a : Point, b : Square)
The main reason for the compiler not trusting type annotations is typescript unsoundness, that allows you to perform type casts on variables that originally have incompatible types.
Another reason is that typescript uses structural typing, meaning that a value being compatible with a class does not necessarily imply that such value is an instance of that class.
from mlogjs.
Related Issues (20)
- [bug] Using double quotes in strings makes the generated code unparseable HOT 1
- [bug] Variables modified inside expressions don't behave correctly
- Add a `getBuildings` helper function.
- [bug] Macros incorrectly bind to mutable variables
- Optimize `Vars.this.x` to `Vars.thisx`
- Improve formatting of the `print` function HOT 2
- Improve examples in the documentation
- Alternative syntax for `setProp`
- Add support for mlog color literals HOT 1
- Remove world processor functions from the global scope
- Drop support for `typeof`
- Add watch mode to the compiler CLI
- how to use `setProp`? HOT 1
- Breaking out of a for loop generates jump null HOT 1
- Useless jumps with nested if HOT 1
- [bug] Using labels in asm breaks jump addresses HOT 2
- Bad optimisation on Vars.time HOT 9
- Code optimization misses forward modification in loops
- Reassigning function parameters breaks function calls HOT 1
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 mlogjs.