-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript code generation backlog #65
Comments
Traits can also introduce method definitions that can be inherited by classes, so they're not just for pattern matching! |
[EDIT: actually we'll do it the JS way in the new parser so this shouldn't be necessary] |
|
|
fun x -> {t1 = gt 1 2; t2 = 1}
//│ // Prelude
//│ function gt(x, y) {
//│ if (arguments.length === 2) {
//│ return x > y;
//│ }else {
//│ return (y) => x > y;
//│ }
//│ }
//│ let res;
//│ // Query 1
//│ res = ((x) => {
//│ t1: gt(1)(2),
//│ t2: 1
//│ });
//| // ((x) => {t1: gt(1)(2), t2: 1}) is illegal
//│ // End of generated code
//│ res: anything -> {t1: bool, t2: 1}
//│ = > undefined |
@andongfan would you like to try and tackle some of this issues, including the new one? @chengluyu Is the list of issues on this ticket up to date? I feel like a few have been solved already. |
I think I can have a try :) |
|
We didn't handle the case. Since when can we use primes in the identifiers? |
They've always been supported in ML-family languages like OCaml and Haskell 😛 |
// Javascript code generated from
// def foo = 1 / 2
const foo = 1 / 2;
// Expecting a truncation operation here. like:
const foo = Math.trunc(1 / 2); |
@zhao-huang Good catch! The initial context in |
|
|
|
|
CC @chengluyu |
After a quick check, I found that the code for outputting type inference results and execution results in |
It probably changed because |
Removed bad solution.Thanks for the pointer! We can temporarily fix this by replacing this line (https://github.com/hkust-taco/mlscript/blob/febbc0ba04c1b6b1821c86ddf9d5696d5fb05a30/shared/src/test/scala/mlscript/DiffTests.scala#L605) with case NuFunDef(_, nme, snme, tparams, bod) => Then,
I propose the PR to fix this. |
I couldn't for the life of me quickly figure out what was going on here because the JS backend infrastructure is so damn opaque and undebuggable. For example there's no way to visualize what's going wrong in the scope graph. I really don't understand why you haven't integrated it with the tracing infrastructure @chengluyu @NeilKleistGao – it shouldn't be hard at all. |
|
I guess this is another problem caused by the code in #186. We really need to refactor the code in |
|
|
r with { x: 1 }
//│ {x: 1}
//│ res
//│ = { x: 1 }
:e // TODO support
let r = new {}
//│ ╔══[ERROR] Unexpected type `anything` after `new` keyword
//│ ║ l.80: let r = new {}
//│ ╙── ^^
//│ let r: error
//│ Code generation encountered an error:
//│ Unsupported `new` class term: Bra(rcd = true, Rcd())
:ge
r : Object
//│ Object
//│ Code generation encountered an error:
//│ unguarded recursive use of by-value binding r
:ge
r with { x: 1 }
//│ error & {x: 1}
//│ Code generation encountered an error:
//│ unguarded recursive use of by-value binding r |
|
|
|
When working on #53, I met a lot of things that we could improved in the future. Here are them.
Find a neat way to store query results. Requirements:
Source
ImplementThis syntax might be changed in the new parser.Class.Member instance
calling convention. SourceAdd timeout to
stream.read()
otherwise we will occasionally suffer from infinite loops. Source (Fixed in Add timeout to prevent rogue tests from running forever #126)Automatically check references to unimplemented variables. Source
Support merging arrays inThe semantics ofwithConstruct
. Source TBD.with
might be changed.Some
// TODO
introduced in commits from Test JavaScript code generation #53. Source TBD.As for 1 Aug, 2022. The
// TODO
s are as follows. They are not urgent at this moment.Blk
.mlscript/shared/src/main/scala/mlscript/JSBackend.scala
Lines 177 to 178 in ba99965
mlscript/shared/src/main/scala/mlscript/JSBackend.scala
Lines 482 to 485 in ba99965
mlscript/shared/src/main/scala/mlscript/codegen/Codegen.scala
Lines 415 to 416 in ba99965
Typer
.mlscript/shared/src/main/scala/mlscript/codegen/Scope.scala
Lines 23 to 26 in ba99965
mlscript/shared/src/main/scala/mlscript/codegen/Scope.scala
Lines 45 to 51 in ba99965
Trait test in pattern matching has not been implemented. This can be done via
Symbol
.The text was updated successfully, but these errors were encountered: