reasonml / reason

Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems
http://reasonml.github.io
MIT License
10.08k stars 425 forks source link

String literals and String module issues #2656

Closed lojikil closed 1 day ago

lojikil commented 2 years ago

Overview

Ok, I worked with @yawaramin (huge thank you to them) on the ReasonML forums to narrow this down. I was clearly misreading the String module, so that's fixed; I'll attempt to figure out what the source of Parsing issues I've seen are. Namely, I've had issues strings with escapes, esp \".

I ran into this in a different context, wherein Escaped strings cause the compiler to complain about missing braces, but I ran into a similar edge case today:

Reason # let src1 = "\"test\""foo\"";
let src1: string = "\"test\"";
Reason # String.length(src1);
- : int = 6
yawaramin commented 2 years ago

Discussion in https://reasonml.chat/t/string-literals-and-string-module-issues/2662

anmonteiro commented 1 day ago

adding a space to make it obvious this is a syntax error

let src1 = "\"test\"" foo\"";