⭐️ A friendly language for building type-safe, scalable systems!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use existing atom escape code

authored by

Benjamin Milde and committed by
Louis Pilfold
d43ef83b d2424a53

+4 -19
+2 -17
compiler-core/src/codegen.rs
··· 9 9 Result, 10 10 }; 11 11 use ecow::EcoString; 12 + use erlang::escape_atom_string; 12 13 use itertools::Itertools; 13 14 use std::fmt::Debug; 14 15 ··· 115 116 .chain(native_modules) 116 117 .unique() 117 118 .sorted() 118 - .map(|m| Self::format_atom(&m)) 119 + .map(|m| escape_atom_string((&m).clone().into())) 119 120 .join(",\n "); 120 121 121 122 // TODO: When precompiling for production (i.e. as a precompiled hex ··· 153 154 ); 154 155 155 156 writer.write(&path, &text) 156 - } 157 - 158 - fn format_atom(s: &EcoString) -> EcoString { 159 - let mut chars = s.chars(); 160 - 161 - let Some(first) = chars.next() else { 162 - return "''".into(); 163 - }; 164 - 165 - let needs_escape = |c: char| !(c.is_alphanumeric() || c == '_' || c == '@'); 166 - 167 - if !first.is_ascii_lowercase() || chars.any(needs_escape) { 168 - format!("'{}'", s).into() 169 - } else { 170 - s.clone() 171 - } 172 157 } 173 158 } 174 159
+1 -1
compiler-core/src/erlang.rs
··· 654 654 } 655 655 } 656 656 657 - fn escape_atom_string(value: String) -> EcoString { 657 + pub fn escape_atom_string(value: String) -> EcoString { 658 658 if is_erlang_reserved_word(&value) { 659 659 // Escape because of keyword collision 660 660 eco_format!("'{value}'")
+1 -1
test/external_only_erlang/test.sh
··· 33 33 exit 1 34 34 fi 35 35 36 - echo Running erlang shippment should succeed 36 + echo Running erlang shipment should succeed 37 37 g export erlang-shipment 38 38 grep "external_only_erlang_ffi" "build/erlang-shipment/external_only_erlang/ebin/external_only_erlang.app" 39 39