Skip to content

Commit b8a02e7

Browse files
committed
test: add trait cast test
1 parent 1675b16 commit b8a02e7

File tree

3 files changed

+83
-13
lines changed

3 files changed

+83
-13
lines changed

src/ast/expects/trait_diag.pi.expect

Lines changed: 82 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,76 @@
602602
},
603603
},
604604
},
605+
PLDiag {
606+
raw: PLDiagRaw {
607+
code: Err(
608+
THE_TARGET_TRAIT_CANNOT_BE_INSTANTIATED,
609+
),
610+
help: None,
611+
labels: [
612+
PLLabel {
613+
file: "",
614+
txt: Some(
615+
(
616+
"the method `{}` of trait `{}` has generic params, which makes it uninstantiatable",
617+
[
618+
"hash",
619+
"Hash",
620+
],
621+
),
622+
),
623+
range: Range {
624+
start: Pos {
625+
line: 5,
626+
column: 5,
627+
offset: 99,
628+
},
629+
end: Pos {
630+
line: 5,
631+
column: 41,
632+
offset: 135,
633+
},
634+
},
635+
},
636+
PLLabel {
637+
file: "",
638+
txt: Some(
639+
(
640+
"trait type `{}`",
641+
[
642+
"Hash",
643+
],
644+
),
645+
),
646+
range: Range {
647+
start: Pos {
648+
line: 124,
649+
column: 9,
650+
offset: 1811,
651+
},
652+
end: Pos {
653+
line: 124,
654+
column: 17,
655+
offset: 1819,
656+
},
657+
},
658+
},
659+
],
660+
source: None,
661+
range: Range {
662+
start: Pos {
663+
line: 124,
664+
column: 9,
665+
offset: 1811,
666+
},
667+
end: Pos {
668+
line: 124,
669+
column: 17,
670+
offset: 1819,
671+
},
672+
},
673+
},
674+
},
605675
PLDiag {
606676
raw: PLDiagRaw {
607677
code: Err(
@@ -612,14 +682,14 @@
612682
source: None,
613683
range: Range {
614684
start: Pos {
615-
line: 172,
685+
line: 173,
616686
column: 15,
617-
offset: 2446,
687+
offset: 2475,
618688
},
619689
end: Pos {
620-
line: 172,
690+
line: 173,
621691
column: 17,
622-
offset: 2448,
692+
offset: 2477,
623693
},
624694
},
625695
},
@@ -643,29 +713,29 @@
643713
),
644714
range: Range {
645715
start: Pos {
646-
line: 176,
716+
line: 177,
647717
column: 6,
648-
offset: 2459,
718+
offset: 2488,
649719
},
650720
end: Pos {
651-
line: 176,
721+
line: 177,
652722
column: 7,
653-
offset: 2460,
723+
offset: 2489,
654724
},
655725
},
656726
},
657727
],
658728
source: None,
659729
range: Range {
660730
start: Pos {
661-
line: 176,
731+
line: 177,
662732
column: 6,
663-
offset: 2459,
733+
offset: 2488,
664734
},
665735
end: Pos {
666-
line: 176,
736+
line: 177,
667737
column: 7,
668-
offset: 2460,
738+
offset: 2489,
669739
},
670740
},
671741
},

test/lsp_diag/trait_diag.pi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ pub fn test_trait() void {
121121
st.call_trait();
122122
fn_with_trait(y);
123123
fn_with_trait(y);
124+
let hashtest:Hash = "a";
124125
return;
125126
}
126127

test/main.pi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ pub fn main() i64 {
9696
let bbbb = 1;
9797
let re = ttt.eq(&bbbb);
9898
println!(re);
99-
let hashtest:Hash = "a";
10099
return 0;
101100
}
102101

0 commit comments

Comments
 (0)