Skip to content

Object field names with double underscore are compiled incorrectly #6005

Closed
@DZakh

Description

@DZakh
@module external css: {..} = "./PriceSwitcher.module.scss"

Js.log(css["priceMode_left"])
Js.log(css["priceMode__left"])
Js.log(css["priceMode__foo___left"])

Compiled to the following js:

var css = require("./PriceSwitcher.module.scss");

console.log(css.priceMode_left);
console.log(css.priceMode);
console.log(css.priceMode__foo_);

The second and the third console logs have incorrect field names. The playground: https://rescript-lang.org/try?version=v10.1.2&code=AIWw9gJgrgNgpgAjgDwC5wE4DsCGMEDGAzkQFwIDeAdFQL4IC8CARFQPQAKGAlgXAMoB3bqgIALTFXDR4VIsSLMAUEoBSRKjDABzABQKA2swAOPPgFlIcAPrwAZqmYBdAJRqNWvYZNm4liDa2cA7ObuqaOvokRqa8flbW1nZgYIlBIa5KQA

I've tried different versions, and it works incorrectly for all of them.

This is a common case when using the BEM methodology together with css modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions