trueagi-io / hyperon-experimental

MeTTa programming language implementation
https://metta-lang.dev
MIT License
133 stars 44 forks source link

Weird bug in car-atom #621

Closed ngeiswei closed 5 months ago

ngeiswei commented 5 months ago

What is the problem?

car-atom raises an error on some non empty expression.

How to reproduce the problem?

Run the following code

!(let $s (stringToChars "ab") (car-atom $s))

What would you normally expect?

['a']

What do you get instead?

[(Error (car-atom ('a' 'b')) "car-atom expects a non-empty expression as an argument")]

What else do you have to say?

The following

!(stringToChars "ab")

correctly outputs

[('a' 'b')]

Moreover, the following

!(let $s ('a' 'b') (car-atom $s))

also correctly outputs

['a']

But for some unknown reason, sticking the two together fails.

Necr0x0Der commented 5 months ago

For some reason, stringToChars wraps up the resulting expression into ValueAtom. Apparently, it should not be done this way. I'll fix it.