zeek / spicy

C++ parser generator for dissecting protocols & files.
https://docs.zeek.org/projects/spicy
Other
243 stars 37 forks source link

Error message around <bytes>.decode(...) mention hilti::Charset #1803

Open awelzel opened 1 month ago

awelzel commented 1 month ago

I thought there were some changes that hilti::Charset isn't supposed to be used anymore. Two observations:

1) Mistakenly typing bytes.decode("utf-8") shows a lot of hilti::Charset for me:

[error] ldap/ldap.spicy:987:53-987:70: call does not match any method: <bytes>.decode(<string>)
[error] ldap/ldap.spicy:987:53-987:70:   candidates:
[error] ldap/ldap.spicy:987:53-987:70:   - <bytes>.decode([charset: hilti::Charset = hilti::Charset::UTF8], [errors: hilti::DecodeErrorStrategy = hilti::DecodeErrorStrategy::REPLACE])

2) It seems import hilti works still?

$ cat h.spicy 
module Test;

import hilti;

print b"abc".decode(hilti::Charset::UTF8);
$ spicyc -j h.spicy -o h.hlto
$ spicyc --version
spicyc v1.11.0-dev.262 (4a1b43ef)

Am I confused? :-)

rsmmr commented 1 month ago

Both of these are a result of the layering, where things get lowered from Spicy to HILTI internally, and doing "HILTI stuff" ends up working as well, and error messages may be produced at the HILTI level (where spicy::Charset has turned into hilti::Charset). But yeah, we should try to make this nicer.