summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-10-03 00:25:59 +0800
committerGitHub <noreply@github.com>2024-10-02 18:25:59 +0200
commitf7cb0322c2d7939398a064d2f31b63ed8902b1c6 (patch)
treef29816d57faf31e6d1984db73cc868952d580c3e
parent78983f1876726a49c69d65629ab433ea1310ece1 (diff)
downloadNim-f7cb0322c2d7939398a064d2f31b63ed8902b1c6.tar.gz
improve error messages for illegalCapture (#24214)
ref https://forum.nim-lang.org/t/12536

Use a general recommendation to avoid some weird error messages like
`<ref ref var Test>` etc.
-rw-r--r--compiler/lambdalifting.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim
index 2d38d9a69..54cdfc5bc 100644
--- a/compiler/lambdalifting.nim
+++ b/compiler/lambdalifting.nim
@@ -300,8 +300,8 @@ proc markAsClosure(g: ModuleGraph; owner: PSym; n: PNode) =
     localError(g.config, n.info,
       ("'$1' is of type <$2> which cannot be captured as it would violate memory" &
        " safety, declared here: $3; using '-d:nimNoLentIterators' helps in some cases." &
-       " Consider using a <ref $2> which can be captured.") %
-      [s.name.s, typeToString(s.typ), g.config$s.info])
+       " Consider using a <ref T> which can be captured.") %
+      [s.name.s, typeToString(s.typ.skipTypes({tyVar})), g.config$s.info])
   elif not (owner.typ.isClosure or owner.isNimcall and not owner.isExplicitCallConv or isEnv):
     localError(g.config, n.info, "illegal capture '$1' because '$2' has the calling convention: <$3>" %
       [s.name.s, owner.name.s, $owner.typ.callConv])
.com> 2016-03-26 23:59:59 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2016-03-27 17:43:41 -0700 2812' href='/akkartik/mu/commit/html/013update_operation.cc.html?h=main&id=a654e4ecace2d506d1b10f1dde2c287ebe84ef37'>a654e4ec ^
76755b28 ^
9e751bb8 ^

e5c11a51 ^
4690ce81 ^
4a39d12d ^
a654e4ec ^
e5c11a51 ^
a654e4ec ^
4a39d12d ^
9e751bb8 ^
70f4e9b6 ^
9e751bb8 ^
76755b28 ^

a654e4ec ^



e5c11a51 ^






















a654e4ec ^

76755b28 ^
e5c11a51 ^
a654e4ec ^
204dae92 ^



201458e3 ^
204dae92 ^

201458e3 ^
fd7d8138 ^
204dae92 ^

201458e3 ^
9e751bb8 ^


2b250717 ^
9e751bb8 ^



204dae92 ^



201458e3 ^
204dae92 ^





201458e3 ^
204dae92 ^

797edfd0 ^
76755b28 ^


a654e4ec ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103