-
Notifications
You must be signed in to change notification settings - Fork 121
Fix/issue129 #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/issue129 #134
Changes from all commits
be5e40a
e9d5dbb
e1e93b8
f44d211
cb4cd53
535449c
d828378
e96576b
a6292f3
ef0710b
f87144e
064ba0f
6ac59b1
38c3849
cbc74ed
cda0233
efcecd1
190303b
137a4b6
62fd1c8
79535db
cc70ebe
d64ff0b
7408f0f
50306df
82eea3f
394e023
b0814dc
e443d67
3c93dc8
b2ded26
9d2d880
b900265
f1e81e4
be09e7a
f5b5256
8a6e2ca
6bfcefd
fc05eb9
ff32768
53245d9
8f6c193
1e5001f
47ad813
7b15375
8e27294
775a3af
bb62813
9630ae0
c593086
6faddf2
d972270
06e38ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,11 +27,14 @@ let (@=) it at = {it; at; note = None} | |
| let dummy_obj_sort() = ref (Type.Object Type.Local) | ||
|
|
||
| let dup_var x = VarE (x.it @@ x.at) @? x.at | ||
|
|
||
| let anon sort at = "anon-" ^ sort ^ "-" ^ string_of_pos at.left | ||
|
|
||
| let name_exp e = | ||
| match e.it with | ||
| | VarE x -> [], e, dup_var x | ||
| | _ -> | ||
| let x = ("anon-val-" ^ string_of_pos (e.at.left)) @@ e.at in | ||
| let x = anon "val" e.at @@ e.at in | ||
| [LetD (VarP x @! x.at, e) @? e.at], dup_var x, dup_var x | ||
|
|
||
| let assign_op lhs rhs_f at = | ||
|
|
@@ -164,8 +167,7 @@ seplist1(X, SEP) : | |
| | id=ID | ||
| { fun _ _ -> id @@ at $sloc } | ||
| | (* empty *) | ||
| { fun sort sloc -> | ||
| ("anon-" ^ sort ^ "-" ^ string_of_pos (at sloc).left) @@ at sloc } | ||
| { fun sort sloc -> anon sort (at sloc) @@ at sloc } | ||
|
|
||
| %inline var_opt : | ||
| | (* empty *) { Const @@ no_region } | ||
|
|
@@ -456,9 +458,9 @@ exp : | |
| { e } | ||
| | d=dec_var | ||
| { DecE(d, ref Type.Pre) @? at $sloc } | ||
| case : | ||
|
|
||
|
|
||
| case : | ||
| | CASE p=pat_nullary e=exp | ||
| { {pat = p; exp = e} @@ at $sloc } | ||
|
|
||
|
|
@@ -558,15 +560,22 @@ dec : | |
| | e=exp_nondec | ||
| { ExpD e @? at $sloc } | ||
| (* TODO(andreas): move to dec_nonvar once other production is gone *) | ||
| | s=obj_sort xf=id_opt EQ? efs=obj_body | ||
| { let anon = if s.it = Type.Actor then "actor" else "object" in | ||
| let efs' = | ||
| | s=obj_sort id_opt=id? EQ? efs=obj_body | ||
| { let efs' = | ||
| if s.it = Type.Object Type.Local | ||
| then efs | ||
| else List.map share_expfield efs | ||
| in | ||
| let p = VarP(xf anon $sloc) @! at $sloc in | ||
| LetD(p, ObjE(s, xf anon $sloc, efs') @? at $sloc) @? at $sloc } | ||
| let r = at $sloc in | ||
| (* desugar anonymous objects to ExpD, named ones to LetD. *) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doing desugaring in the Parser causes confusing type error messages if the type checker wants to pretty print expressions, i.e. code that is different from what the user wrote.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with trivial desugarings like this being done in the parser. Don't think we want to print ASTs in error messages anyway, that's what source locations are for.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But even if we don’t print actual AST fragments, there is still a risk to say “in a But not a big deal and we have more important things to do, so I will not press this issue. |
||
| match id_opt with | ||
| | None -> | ||
| let sort = if s.it = Type.Actor then "actor" else "object" in | ||
| let x = anon sort r @@ r in | ||
| ExpD(ObjE(s, x, efs') @? r) @? r | ||
| | Some x -> | ||
| let p = VarP x @! r in | ||
| LetD(p, ObjE(s, x, efs') @? r) @? r } | ||
|
|
||
| func_dec : | ||
| | tps=typ_params_opt p=pat_nullary rt=return_typ? fb=func_body | ||
|
|
@@ -592,7 +601,7 @@ obj_body : | |
|
|
||
| class_body : | ||
| | EQ xf=id_opt efs=obj_body { xf "object" $sloc, efs } | ||
| | efs=obj_body { ("anon-object-" ^ string_of_pos (at $sloc).left) @@ at $sloc, efs } | ||
| | efs=obj_body { anon "object" (at $sloc) @@ at $sloc, efs } | ||
|
|
||
|
|
||
| (* Programs *) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // status.as | ||
| type Status = { | ||
| failed_ : Nat; | ||
| passed_ : Nat; | ||
| pending_ : Nat; | ||
| }; | ||
|
|
||
| let appendStatus = func (x : Status, y : Status) : Status { | ||
| new { | ||
| failed_ = x.failed_ + y.failed_; | ||
| passed_ = x.passed_ + y.passed_; | ||
| pending_ = x.pending_ + y.pending_; | ||
| }; | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.