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

Problem with non-ascii characters in variable names #47

Closed
woylie opened this issue May 14, 2020 · 2 comments · Fixed by #97
Closed

Problem with non-ascii characters in variable names #47

woylie opened this issue May 14, 2020 · 2 comments · Fixed by #97
Labels

Comments

@woylie
Copy link

woylie commented May 14, 2020

I encountered a problem with elm-syntax while using elm-analyse on the elm-visualization package.

@jfmengels pointed out that the problem is caused by the variable names ε2 and ρ.

Original issue opened here: stil4m/elm-analyse#242

Elm-analyse returns a FileLoadError (Could not load file due to: Unexpected parse error) for the module Zoom.Interpolation of elm-visualization.

https://github.com/gampleman/elm-visualization/blob/2.1.1/src/Zoom/Interpolation.elm

@MartinSStewart
Copy link
Collaborator

I had a look at this. It looks like elm-syntax checks that function names contain only alpha numeric characters. This excludes letters outside of the ascii alphabet.

There doesn't seem to be an easy fix to this because elm-syntax needs to know if a character is uppercase or lowercase and Elm doesn't provide any API for doing that in general with Unicode characters.

@jfmengels jfmengels added the bug label Jan 21, 2021
@MartinSStewart
Copy link
Collaborator

MartinSStewart commented Jan 23, 2021

I thought of a hacky solution. We can exploit the fact that String.toLower and String.toUpper do support unicode to implement our own Char.isLower and Char.isUpper

isLower char = 
    let 
         stringChar = String.fromChar char
    in
    case (String.toUpper stringChar == stringChar, String.toLower stringChar == stringChar) of
        (False, True) -> True
        _ -> False

isUpper char = 
    let 
         stringChar = String.fromChar char
    in
    case (String.toUpper stringChar == stringChar, String.toLower stringChar == stringChar) of
        (True, False) -> True
        _ -> False

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

Successfully merging a pull request may close this issue.

3 participants