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

IO.println: Type error: expected str to be Text, but got Function #5961

Closed
JaroslavTulach opened this issue Mar 16, 2023 · 4 comments · Fixed by #6223
Closed

IO.println: Type error: expected str to be Text, but got Function #5961

JaroslavTulach opened this issue Mar 16, 2023 · 4 comments · Fixed by #6223
Assignees
Labels
--data corruption or loss Important: data corruption or loss -compiler -libs Libraries: New libraries to be implemented
Milestone

Comments

@JaroslavTulach
Copy link
Member

I am trying to use IO.println to "debug" my #5956 program. However the println statement is causing my program to fail with:

Execution finished with an error: Type error: expected `str` to be Text, but got Function.
        at <enso> IO.println(Internal)
        at <enso> Function.<|(Internal)

It is not really productive when debugging of something turns into hunting for a reason why the debugging itself does not work. I believe the IO.println method should never fall and always print something.

The reproducer is:

from Standard.Base import all
import Standard.Base

main = 
    raw = Vector.from_polyglot_array []
    IO.println <| (Meta.type_of raw).to_text
    IO.println <| (Meta.type_of raw)
    Meta.type_of raw

surprisingly the 1st IO.println statement succeeds and prints:

Vector.type.to_text[Vector.enso:601-1763]

however the second statement yields the exception Type error: expected str to be Text, but got Function..

@JaroslavTulach JaroslavTulach added -compiler -libs Libraries: New libraries to be implemented --data corruption or loss Important: data corruption or loss labels Mar 16, 2023
@jdunkerley
Copy link
Member

Given that IO.println not supported well within the IDE, this is not on milestone.
It could make for a nice first ticket where the value is to_textd if not Text.

@wdanilo
Copy link
Member

wdanilo commented Mar 22, 2023

@jdunkerley default to to_text is nice, but I think the problem here is more serious. If I understand that correctly, engine thinks that the right side of print here IO.println <| (Meta.type_of raw) is a not-evaluated function. If so, this is something really broken. Do I understand it correctly?

@JaroslavTulach
Copy link
Member Author

Given that IO.println not supported well within the IDE, this is not on milestone.

When IO.println is crashing the execution, it is hard to fix anything - including the IDE. Ignoring the problem will strike back.

It could make for a nice first ticket where the value is to_textd if not Text.

I am not sure. I certainly found the logic of to_(display)_text when printing an error very convoluted. Otherwise I'd fix it without reporting an issue. Good luck to a newcomer who selects this a a fist issue.

@wdanilo
Copy link
Member

wdanilo commented Mar 22, 2023

Good luck to a newcomer who selects this a a fist issue.

😂 We should probably then remove this flag :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
--data corruption or loss Important: data corruption or loss -compiler -libs Libraries: New libraries to be implemented
Projects
Archived in project
4 participants