Skip to content

docs correct the fromCode range description - #156

Open
theluckystrike wants to merge 1 commit into
gren-lang:mainfrom
theluckystrike:ws/fromcode-doc-range-0920-0900
Open

theluckystrike wants to merge 1 commit into
gren-lang:mainfrom
theluckystrike:ws/fromcode-doc-range-0920-0900

Conversation

@theluckystrike

Copy link
Copy Markdown

Fixes #149

The fromCode doc comment said numbers outside the unicode range return the replacement character. The kernel uses String.fromCodePoint, which throws a RangeError for those inputs. This updates the doc comment and drops the now wrong example.

@robinheghan

Copy link
Copy Markdown
Member

Hi!

Gren code should not throw exceptions, so changing the docs is not a way to fix this issue.

For backwards compatibility, we catch the exception and return the replacement character. We should also add a unit test to verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Char.fromCode throws a RangeError out of range, but its documentation says it returns U+FFFD

2 participants