tscircuit / tscircuit/schematic-trace-solver
getColorFromString returns hsl(NaN, ...) for very long strings
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13
- Forks
- 314
- Avg merge
- 9h 3m
- Merged PRs (30d)
- 132
Description
getColorFromString builds its hash with acc * 31 + charCodeAt(0), which overflows to Infinity for a long enough string. hash % 360 is then NaN, so it returns an invalid color:
getColorFromString("n".repeat(300)) // -> "hsl(NaN, 100%, 50%, 1)"
A hue of NaN is not a parseable color. It should return a valid hue for any input string.
Contributor guide
No contributing guide indexed for this repository
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 at the getColorFromString entry point and reproduce the issue with a 300-character string. Trace how the hash is calculated and verify the change with the provided example; done means every input, including very long strings, produces a valid hue rather than NaN.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- design
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100