Skip to content
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

Coffeescript tagged template literals are broken #289

Closed
greghuc opened this issue Jan 25, 2023 · 3 comments · Fixed by #294
Closed

Coffeescript tagged template literals are broken #289

greghuc opened this issue Jan 25, 2023 · 3 comments · Fixed by #294
Assignees
Labels
bug Something isn't working coffeescript CoffeeScript compatibility related

Comments

@greghuc
Copy link

greghuc commented Jan 25, 2023

Hi there

I'm exploring porting a Coffeescript project to Civet, and discovered that CS tagged template literals are broken.

Example

Try this in the Civet Playground - it's the example used in the CS docs. The example breaks at 'upperCaseExpr"""' (note the no space between function call and multiline string).

"civet coffeeCompat"

upperCaseExpr = (textParts, expressions...) ->
  textParts.reduce (text, textPart, i) ->
    text + expressions[i - 1].toUpperCase() + textPart

greet = (name, adjective) ->
  upperCaseExpr"""
               Hi #{name}. You look #{adjective}!
               """

greet("greg", "awesome")

FYI

FYI I wrote the CS2 support for tagged template literals, and interpolated strings.

Thanks for all your work on Civet. It's looking like a very promising successor to Coffeescript, assuming the migration path is sane.

@edemaine edemaine added bug Something isn't working coffeescript CoffeeScript compatibility related labels Jan 25, 2023
@edemaine
Copy link
Collaborator

Nice catch, and thanks for the report! This should be an easy fix.

Note that foo'''...''' also doesn't parse (though it's an admittedly less useful form of tagged template literals).

@edemaine edemaine self-assigned this Jan 25, 2023
edemaine added a commit that referenced this issue Jan 25, 2023
* `StringLiteral` is now always a string literal;
  no more `BasicStringLiteral`
* `TemplateLiteral` now contains all CoffeeScript string interpolations
  (`"` and `"""` and even `'''` which transpiles to a template literal),
  though occasionally returns `StringLiteral` when there is no interpolation.
  * Fixes #289
* Important to check for CoffeeScript double-quoted strings via
  `TemplateLiteral` before regular double-quoted strings via `StringLiteral`.
STRd6 pushed a commit that referenced this issue Jan 25, 2023
* Template literals as object keys

* Refactor StringLiteral vs. TemplateLiteral

* `StringLiteral` is now always a string literal;
  no more `BasicStringLiteral`
* `TemplateLiteral` now contains all CoffeeScript string interpolations
  (`"` and `"""` and even `'''` which transpiles to a template literal),
  though occasionally returns `StringLiteral` when there is no interpolation.
  * Fixes #289
* Important to check for CoffeeScript double-quoted strings via
  `TemplateLiteral` before regular double-quoted strings via `StringLiteral`.
@edemaine
Copy link
Collaborator

Should be fixed in the 0.5.58 release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working coffeescript CoffeeScript compatibility related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants