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

UTF8 parsed incorrectly for literate agda files #2536

Closed
twanvl opened this issue Apr 6, 2017 · 4 comments
Closed

UTF8 parsed incorrectly for literate agda files #2536

twanvl opened this issue Apr 6, 2017 · 4 comments
Assignees
Labels
lexer literate-agda platform: windows Any issue specific to Microsoft Windows type: bug Issues and pull requests about actual bugs
Milestone

Comments

@twanvl
Copy link

twanvl commented Apr 6, 2017

The following literate agda file (test.lagda) gives a parse error, at least on Windows:

\begin{code}
module _ where
id : {A : Set} → A → A
id x = x
\end{code}

Error:

test.lagda:3,16: Parse error
→<ERROR>
 A → A
id x = x

This is clearly an encoding issue.

Looking at the agda source code, it seems that non-literate .agda files are opened with Agda.Utils.IO.UTF8.readTextFile (see here), while literate agda files use Prelude.readFile (see here).

Version: Agda version 2.6.0-6ad752f, on windows 7.
Note: the agda command line gives no errors, but agda-mode from emacs does.

@andreasabel
Copy link
Member

This might be an omission. @vlopezj , can you take a look?

@andreasabel andreasabel added lexer literate-agda platform: windows Any issue specific to Microsoft Windows type: bug Issues and pull requests about actual bugs labels Apr 7, 2017
@andreasabel andreasabel added this to the 2.5.3 milestone Apr 7, 2017
@vlopezj vlopezj self-assigned this Apr 8, 2017
vlopezj added a commit that referenced this issue Apr 8, 2017
We use our internal function to read literate files. This function
has better cross-platform support (e.g. Windows).
@vlopezj
Copy link
Contributor

vlopezj commented Apr 8, 2017

@twanvl: I applied your suggestion, it is now on both the stable-2.5 and the master branch. Can you check if it works on Windows now?

@twanvl
Copy link
Author

twanvl commented Apr 10, 2017

I have tested it, and the issues is fixed on the master branch on Windows.

@asr asr closed this as completed Apr 10, 2017
@nad
Copy link
Contributor

nad commented Apr 19, 2017

The readFile function uses the current locale to determine the encoding, at least on some systems. Agda sources must always be UTF8-encoded, and we should always use the UTF8 encoding when reading and writing Agda sources.

I can trigger a similar problem on my Linux machine:

$ LC_CTYPE=C agda test.lagda 
/tmp/test.lagda: hGetContents: invalid argument (invalid byte
sequence)

I suggest that we add test cases that set LC_CTYPE to C, like I do above, both for literate and for non-literate files.

@nad nad reopened this Apr 19, 2017
@UlfNorell UlfNorell modified the milestones: 2.5.4, 2.5.3 Aug 9, 2017
nad added a commit that referenced this issue May 9, 2018
@nad nad closed this as completed May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lexer literate-agda platform: windows Any issue specific to Microsoft Windows type: bug Issues and pull requests about actual bugs
Projects
None yet
Development

No branches or pull requests

6 participants