mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
minor improvements
This commit is contained in:
parent
2cad4b3e21
commit
6b2d2e3406
2 changed files with 8 additions and 3 deletions
|
@ -15,12 +15,14 @@ thread_local! {
|
|||
static SUFFIXED_ANSWER_COUNTER: Cell<usize> = const { Cell::new(0) };
|
||||
}
|
||||
|
||||
/// Generates a unique identifier, useful for intermediate items during desugaring
|
||||
/// Generates a unique identifier, useful for intermediate items during desugaring.
|
||||
fn next_unique_suffixed_ident() -> String {
|
||||
SUFFIXED_ANSWER_COUNTER.with(|counter| {
|
||||
let count = counter.get();
|
||||
counter.set(count + 1);
|
||||
|
||||
// # is used as prefix because it's impossible for code authors to define names like this.
|
||||
// This makes it easy to see this identifier was created by the compiler.
|
||||
format!("#!a{}", count)
|
||||
})
|
||||
}
|
||||
|
@ -56,7 +58,7 @@ fn init_unwrapped_err<'a>(
|
|||
}
|
||||
None => {
|
||||
// Provide an intermediate answer expression and pattern when unwrapping a
|
||||
// (sub) expression
|
||||
// (sub) expression.
|
||||
// e.g. `x = foo (bar!)` unwraps to `x = Task.await (bar) \#!a0 -> foo #!a0`
|
||||
let answer_ident = arena.alloc(next_unique_suffixed_ident());
|
||||
let sub_new = arena.alloc(Loc::at(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue