1
1
mirror of https://github.com/tweag/nickel.git synced 2024-09-20 08:05:15 +03:00

Retype ident fields

This commit is contained in:
Yannik Sander 2021-11-13 16:26:21 +01:00 committed by Yannik Sander
parent 7f835c9b94
commit 79adfecab4
5 changed files with 50 additions and 1 deletions

1
- Symbolic link
View File

@ -0,0 +1 @@
/nix/store/jnzl9smbj3afqmi0zvzq88g5vfq0hpcg-poppler-utils-21.06.1

40
examples/a.ncl Normal file
View File

@ -0,0 +1,40 @@
let func: Num -> Num -> Num -> Num = fun x y z =>
x +
y +
z
in
let EqualsTo = fun referenceValue label value =>
if referenceValue == value then
value
else
contracts.blame label in
let IsTrue = EqualsTo true in
let Checked = {
b.string | #IsTrue
} in
let config: {
b: {
string : Bool,
},
sum : Num,
jump: Bool,
} = {
b."string" = true,
jump = b.string,
sum = func 1 1 1
} in
let rec : { a: Str, b: Str }= {
a ="String",
b = a,
}
in
(config | #Checked).b.string

6
examples/b.ncl Normal file
View File

@ -0,0 +1,6 @@
let abc = {
foo.baz.bar = 1,
bar = foo.baz
} in
abc.foo.baz

0
examples/lists/tst.ncl Normal file
View File

View File

@ -671,6 +671,7 @@ fn type_check_<S, E>(
for (id, _) in stat_map {
envs.insert(id.clone(), ty_dyn.clone());
linearizer.retype_ident(lin, id, ty_dyn.clone())
}
stat_map
@ -690,7 +691,8 @@ fn type_check_<S, E>(
if let Term::RecRecord(..) = t.as_ref() {
for (id, rt) in stat_map {
let tyw = binding_type(rt.as_ref(), &envs, state.table, strict);
envs.insert(id.clone(), tyw);
envs.insert(id.clone(), tyw.clone());
linearizer.retype_ident(lin, id, tyw);
}
}