Support ! in symbols provided to host

This commit is contained in:
Agus Zubiaga 2024-10-16 15:34:35 -03:00
parent b80f44738f
commit 75856ae804
No known key found for this signature in database
3 changed files with 10 additions and 10 deletions

View file

@ -4646,7 +4646,7 @@ impl LayoutId {
// Returns something like "#UserApp_foo_1" when given a symbol that interns to "foo"
// and a LayoutId of 1.
pub fn to_symbol_string(self, symbol: Symbol, interns: &Interns) -> String {
let ident_string = symbol.as_str(interns);
let ident_string = symbol.as_str(interns).trim_end_matches('!');
let module_string = interns.module_ids.get_name(symbol.module_id()).unwrap();
format!("{}_{}_{}", module_string, ident_string, self.0)
}
@ -4654,12 +4654,12 @@ impl LayoutId {
// Returns something like "roc__foo_1_exposed" when given a symbol that interns to "foo"
// and a LayoutId of 1.
pub fn to_exposed_symbol_string(self, symbol: Symbol, interns: &Interns) -> String {
let ident_string = symbol.as_str(interns);
let ident_string = symbol.as_str(interns).trim_end_matches('!');
format!("roc__{}_{}_exposed", ident_string, self.0)
}
pub fn to_exposed_generic_symbol_string(self, symbol: Symbol, interns: &Interns) -> String {
let ident_string = symbol.as_str(interns);
let ident_string = symbol.as_str(interns).trim_end_matches('!');
format!("roc__{}_{}_exposed_generic", ident_string, self.0)
}
}

View file

@ -1,9 +1,9 @@
platform "effects"
requires {} { main : {} => {} }
requires {} { main! : {} => {} }
exposes []
packages {}
imports []
provides [mainForHost]
provides [mainForHost!]
mainForHost : {} => {}
mainForHost = \{} -> main {}
mainForHost! : {} => {}
mainForHost! = \{} -> main! {}

View file

@ -1,9 +1,9 @@
app [main] { pf: platform "effects-platform/main.roc" }
app [main!] { pf: platform "effects-platform/main.roc" }
import pf.Effect
main : {} => {}
main = \{} ->
main! : {} => {}
main! = \{} ->
line = Effect.getLine! {}
if line == "secret" then