reason icon indicating copy to clipboard operation
reason copied to clipboard

better error message for empty string in objects

Open bobzhang opened this issue 6 years ago • 4 comments

Moved from https://github.com/BuckleScript/bucklescript/issues/3494

It would be nice that reason do some sanity check in the first place.

Defining a Js.t object such as let obj = {"": someValue}; throws the following for me:

Fatal error: exception File "lam_methname.ml", line 135, characters 2-8: Assertion failed
File "", line 1:
Error: Error while running external preprocessor

I encountered the problem while trying to define an xstate transient transition which gives special meaning to the empty string key.

Side note: Putting the Js.t example above on the "Try Reason" website currently causes the site to completely crash.

bobzhang avatar Apr 17 '19 01:04 bobzhang

This works OK in Reason:

$ echo 'let obj = {"": someValue};' | ./_build/install/default/bin/refmt

 let obj = {"": someValue};

Looks like the stack trace is referring to BuckleScript internals.

anmonteiro avatar Dec 01 '19 20:12 anmonteiro

Ah, I am suggesting reason do a sanity check

bobzhang avatar Dec 02 '19 05:12 bobzhang

Do you think this needs to be reopened? Could you explain better what you had in mind for a sanity check?

Does that mean we shouldn't support objects with empty keys?

anmonteiro avatar Dec 02 '19 05:12 anmonteiro

relevant to https://github.com/BuckleScript/bucklescript/issues/3494 may need some discussion with the proper behavior with empty string

bobzhang avatar Dec 02 '19 05:12 bobzhang