Allow strip_binds in Pattern.drop_lit
This commit is contained in:
parent
4c3eaeff1c
commit
ffea85ece9
|
@ -214,7 +214,7 @@ export function lit(v: AnyValue): P.Pattern {
|
||||||
return P.Pattern.lit(P.asAnyAtom(v));
|
return P.Pattern.lit(P.asAnyAtom(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function drop_lit(p: P.Pattern): AnyValue | null {
|
export function drop_lit(p: P.Pattern, strip_binds = false): AnyValue | null {
|
||||||
const e = new Error();
|
const e = new Error();
|
||||||
|
|
||||||
function walkEntries(target: AnyValue[], entries: EncodableDictionary<Ref, AnyValue, P.Pattern<Ref>>): void {
|
function walkEntries(target: AnyValue[], entries: EncodableDictionary<Ref, AnyValue, P.Pattern<Ref>>): void {
|
||||||
|
@ -253,6 +253,11 @@ export function drop_lit(p: P.Pattern): AnyValue | null {
|
||||||
}
|
}
|
||||||
case 'lit':
|
case 'lit':
|
||||||
return P.fromAnyAtom(p.value);
|
return P.fromAnyAtom(p.value);
|
||||||
|
case 'bind':
|
||||||
|
if (strip_binds) {
|
||||||
|
return walk(p.pattern);
|
||||||
|
}
|
||||||
|
// fall through
|
||||||
default:
|
default:
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue