"slice" expressions with number input within "==" expression gives unexpected result
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
mapbox-gl-js version: v1.11.0
browser: Firefox, Chrome
Steps to Trigger Behavior
Use a slice expression with a number input like this:
["case", ["==", ["slice", {number}, 0, 1], "1"], "True", "Fallback"]
Link to Demonstration
https://jsbin.com/calonadica/1/edit?html,output
Expected Behavior
There is an error logged in the console and the evaluation fails or the fallback value is selected.
Actual Behavior
The fallback value is not selected and there is only the following warning in the console:
Expected first argument to be of type array or string, but found number instead.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing evaluation of the slice expression when its input is a number, then follow how that result is handled inside the == expression. Reproduce the case from the issue in the linked JSBin using Firefox or Chrome. Done means the documented error behavior occurs instead of only a warning and incorrectly selecting the non-fallback branch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100