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

False-positive type error in text mode when pipeline operator is used #257

Closed
zeptometer opened this issue Jan 18, 2021 · 3 comments
Closed

Comments

@zeptometer
Copy link

When compiling this hoge.saty file with text mode,

() |> (fun () -> `a`)

I got the following type error.

$ satysfi --text-mode "text" test/hoge.saty -o main.txt
 ---- ---- ---- ----
  target file: 'main.txt'
  dump file: 'hoge.satysfi-aux' (already exists)
  parsing 'hoge.saty' ...
 ---- ---- ---- ----
  type checking 'hoge.saty' ...
  type check passed. (string)
! [Type Error] file 'hoge.saty' is not a file for generating text; it is of type
      string

It does not happen when I omit the pipeline operator.

(fun () -> `a`) ()
$ satysfi --text-mode "text" test/hoge.saty -o main.txt
 ---- ---- ---- ----
  target file: 'main.txt'
  dump file: 'hoge.satysfi-aux' (already exists)
  parsing 'hoge.saty' ...
 ---- ---- ---- ----
  type checking 'hoge.saty' ...
  type check passed. (string)
  preprocessing 'hoge.saty' ...
 ---- ---- ---- ----
  evaluating texts ...
  evaluation done.
  all cross references were solved.
 ---- ---- ---- ----
  output written on 'main.txt'.
@zeptometer
Copy link
Author

SATySFi version is 0.0.5.

@zeptometer zeptometer changed the title Type error occurs for text mode when pipeline operator is used False-positive type error in text mode when pipeline operator is used Jan 18, 2021
@gfngfn
Copy link
Owner

gfngfn commented Feb 1, 2021

Thank you for reporting! The strange behavior seems fixed at a9d762b. Its cause can be seen in d5884a2 (roughly speaking, the original implementation did not take account of occurrences of string generated by the substitution of type variables).

Example:

$ cat hoge.saty
() |> (fun () -> `a`)
$ satysfi --text-mode "text" hoge.saty -o main.txt      
 ---- ---- ---- ----
  target file: 'main.txt'
  dump file: 'hoge.satysfi-aux' (will be created)
  parsing 'hoge.saty' ...
 ---- ---- ---- ----
  type checking 'hoge.saty' ...
  type check passed. (string)
  preprocessing 'hoge.saty' ...
 ---- ---- ---- ----
  evaluating texts ...
  evaluation done.
  all cross references were solved.
 ---- ---- ---- ----
  output written on 'main.txt'.
$ cat main.txt                    
a

@gfngfn gfngfn closed this as completed Feb 1, 2021
@zeptometer
Copy link
Author

Nice, thank you for fixing it!

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

No branches or pull requests

2 participants