Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Do not generate leading and trailing "" in template expressions. #602

Closed
wants to merge 1 commit into from

Conversation

cristianoc
Copy link
Contributor

@cknitt
Copy link
Member

cknitt commented Jul 6, 2022

Is this not reintroducing #365?

@cristianoc
Copy link
Contributor Author

Is this not reintroducing #365?

Good catch. And it has other problems too.

@cristianoc
Copy link
Contributor Author

Just writing down some notes here.

This reliance on indirect type checking by putting "" at either end of string concatenation seems brittle.
Also there seem to be several layers of sediment left presumably from old ways of doing things.

So `stuff` is the same as js`stuff` by convention I think.

Then there is j`stuff` which somehow obeys different rules. So in j`$x` the $x actually has a meaning. And x does not need to be a string. The consequence of this is that "" + x is not the same as x when x is not a string. So removing empty string concatenation in the back-end of the compiler is also delicate as it's easy to do it wrong (3 + "" can't be removed).

Then there's json`stuff` which I don't know maybe it's the same as j but old, not really sure. Are they really treated in the same way at every stage in the compiler? Not sure.

All this is represented internally by putting together strings that have a tag "j" or "js" or "json".
In addition to all that, strings produced by the parser are now by default unicode, and that uses the tag "*j". But, there's also the OCaml parser for .ml files which will never generate "*j" for normal strings.

In addition to all this, there's some half attempt to also use a type "unicode" inside the back-end of the compiler, which seems incomplete.

Also, there's a quoting mechanism that happens on dump (code generation) which depends on which kind of string it is.

Goes without saying, all this needs a good cleanup.

@cristianoc
Copy link
Contributor Author

Moving these thoughts to an issue in the compiler repo rescript-lang/rescript#5522

@cristianoc cristianoc closed this Jul 7, 2022
@cristianoc cristianoc deleted the template branch July 23, 2022 04:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

^10.0.0-alpha.1 template literals output "regression"
2 participants