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

"let" expression strips expected type during parsing #7300

Closed
ChrisLoer opened this issue Sep 19, 2018 · 0 comments
Closed

"let" expression strips expected type during parsing #7300

ChrisLoer opened this issue Sep 19, 2018 · 0 comments
Labels

Comments

@ChrisLoer
Copy link
Contributor

This showed up in a bug report as a somewhat cryptic "Type string is not interpolatable" error for a style property of this form:

"fill-color": ["let", 
   "someNumber",
   500,
   [
          "interpolate",
          ["linear"],
          ["var", "someNumber"],
          274,
          "#edf8e9",
          1551,
          "#006d2c"
    ]

The same interpolate expression without using a "let/var" worked just as expected. It turns out the reason was that the color strings (eg "#edf8e9" were getting implicitly coerced to the "color" type because that's the expected type for the fill-color property. Inside the let expression though, the implicit coercion didn't happen.

I think this is just a mistake here:

const result = context.parse(args[args.length - 1], args.length - 1, undefined, bindings);

That undefined should actually be context.expectedType, in order to correctly set the let expression's result type. It looks like we're already doing that in native:

https://github.com/mapbox/mapbox-gl-native/blob/a991eec597541c32682946b541e22ccad0f98dd1/src/mbgl/style/expression/let.cpp#L61

cc @malwoodsantoro @mollymerp @ryanhamley

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants