Skip to content

Commit e510974

Browse files
committed
Fix alias final names
1 parent 42bd0a8 commit e510974

File tree

3 files changed

+48
-19
lines changed

3 files changed

+48
-19
lines changed

src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ entryToScopedIden name e = do
826826
return
827827
ScopedIden
828828
{ _scopedIdenAlias = Just scopedName',
829-
_scopedIdenFinal = helper (e' ^. symbolEntry)
829+
_scopedIdenFinal = e' ^. symbolEntry
830830
}
831831
registerScopedIden si
832832
return si

tests/positive/Isabelle/Program.juvix

+14
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,17 @@ getMessageFromTrigger' {M H} (t : Trigger M H) : Maybe M :=
195195
message := m })})})
196196
:= just m
197197
| _ := nothing;
198+
199+
-- Syntax aliases
200+
201+
Name : Type := Nat;
202+
203+
syntax alias T := Name;
204+
205+
idT (x : T) : T := x;
206+
207+
t : T := 0;
208+
209+
type RR := mkRR {
210+
x : T
211+
};

tests/positive/Isabelle/isabelle/Program.thy

+33-18
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ definition id2 :: "'A \<Rightarrow> 'A" where
1818
fun add_one :: "nat list \<Rightarrow> nat list" where
1919
"add_one [] = []" |
2020
(* hello! *)
21-
"add_one (x # xs) = ((x + 1) # add_one xs)"
21+
"add_one (x' # xs) = ((x' + 1) # add_one xs)"
2222

2323
fun sum :: "nat list \<Rightarrow> nat" where
2424
"sum [] = 0" |
25-
"sum (x # xs) = (x + sum xs)"
25+
"sum (x' # xs) = (x' + sum xs)"
2626

2727
fun f :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" where
28-
"f x y z = ((z + 1) * x + y)"
28+
"f x' y z = ((z + 1) * x' + y)"
2929

3030
fun g :: "nat \<Rightarrow> nat \<Rightarrow> bool" where
31-
"g x y = (if x = f x (N.g y) (M_N.g (M_Main.f y)) then False else True)"
31+
"g x' y = (if x' = f x' (N.g y) (M_N.g (M_Main.f y)) then False else True)"
3232

3333
fun inc :: "nat \<Rightarrow> nat" where
34-
"inc x = (Suc x)"
34+
"inc x' = (Suc x')"
3535

3636
(* dec function *)
3737
fun dec :: "nat \<Rightarrow> nat" where
3838
"dec 0 = 0" |
39-
"dec (Suc x) = x"
39+
"dec (Suc x') = x'"
4040

4141
(* dec' function *)
4242
fun dec' :: "nat \<Rightarrow> nat" where
@@ -45,23 +45,23 @@ fun dec' :: "nat \<Rightarrow> nat" where
4545
(* the zero case *)
4646
(* return zero *)
4747
(* the suc case *)
48-
"dec' x =
49-
(case x of
48+
"dec' x' =
49+
(case x' of
5050
0 \<Rightarrow> 0 |
5151
(Suc y) \<Rightarrow> y)"
5252

5353
fun optmap :: "('A \<Rightarrow> 'A) \<Rightarrow> 'A option \<Rightarrow> 'A option" where
5454
"optmap f' None = None" |
55-
"optmap f' (Some x) = (Some (f' x))"
55+
"optmap f' (Some x') = (Some (f' x'))"
5656

5757
fun pboth :: "('A \<Rightarrow> 'A') \<Rightarrow> ('B \<Rightarrow> 'B') \<Rightarrow> 'A \<times> 'B \<Rightarrow> 'A' \<times> 'B'" where
58-
"pboth f' g' (x, y) = (f' x, g' y)"
58+
"pboth f' g' (x', y) = (f' x', g' y)"
5959

6060
fun bool_fun :: "bool \<Rightarrow> bool \<Rightarrow> bool \<Rightarrow> bool" where
61-
"bool_fun x y z = (x \<and> (y \<or> z))"
61+
"bool_fun x' y z = (x' \<and> (y \<or> z))"
6262

6363
fun bool_fun' :: "bool \<Rightarrow> bool \<Rightarrow> bool \<Rightarrow> bool" where
64-
"bool_fun' x y z = (x \<and> y \<or> z)"
64+
"bool_fun' x' y z = (x' \<and> y \<or> z)"
6565

6666
(* Queues *)
6767
text \<open>
@@ -71,7 +71,7 @@ datatype 'A Queue
7171
= queue "'A list" "'A list"
7272

7373
fun qfst :: "'A Queue \<Rightarrow> 'A list" where
74-
"qfst (queue x v') = x"
74+
"qfst (queue x' v') = x'"
7575

7676
fun qsnd :: "'A Queue \<Rightarrow> 'A list" where
7777
"qsnd (queue v' v'0) = v'0"
@@ -85,10 +85,10 @@ fun pop_front :: "'A Queue \<Rightarrow> 'A Queue" where
8585
v' \<Rightarrow> q')"
8686

8787
fun push_back :: "'A Queue \<Rightarrow> 'A \<Rightarrow> 'A Queue" where
88-
"push_back q x =
88+
"push_back q x' =
8989
(case qfst q of
90-
[] \<Rightarrow> queue [x] (qsnd q) |
91-
q' \<Rightarrow> queue q' (x # qsnd q))"
90+
[] \<Rightarrow> queue [x'] (qsnd q) |
91+
q' \<Rightarrow> queue q' (x' # qsnd q))"
9292

9393
text \<open>
9494
Checks if the queue is empty
@@ -291,11 +291,26 @@ fun getMessageFromTrigger :: "('M, 'H) Trigger \<Rightarrow> 'M option" where
291291
v'1 \<Rightarrow> None)"
292292

293293
fun getMessageFromTrigger' :: "('M, 'H) Trigger \<Rightarrow> 'M option" where
294-
"getMessageFromTrigger' t =
295-
(case t of
294+
"getMessageFromTrigger' t' =
295+
(case t' of
296296
(MessageArrived v') \<Rightarrow>
297297
(case (EnvelopedMessage.packet v') of
298298
(v'0) \<Rightarrow> Some (MessagePacket.message v'0)) |
299299
v'2 \<Rightarrow> None)"
300300

301+
(* Syntax aliases *)
302+
type_synonym Name = nat
303+
304+
fun idT :: "nat \<Rightarrow> Name" where
305+
"idT x' = x'"
306+
307+
definition t :: Name where
308+
"t = 0"
309+
310+
record RR =
311+
x :: nat
312+
313+
fun x :: "RR \<Rightarrow> Name" where
314+
"x (| RR.x = x' |) = x'"
315+
301316
end

0 commit comments

Comments
 (0)