Skip to content

Commit 7fe389c

Browse files
committed
Check for duplicate parameters in shared methods
1 parent 58b51d9 commit 7fe389c

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

py/dml/traits.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,15 @@ def mktrait(site, tname, ancestors, methods, params, sessions, hooks,
324324
del sessions[name]
325325

326326
bad_methods = set()
327-
for (name, (msite, inp, outp, throws, independent, startup, memoized, overridable,
328-
body, rbrace_site)) in list(methods.items()):
327+
for (name, (msite, inp, outp, throws, independent, startup, memoized,
328+
overridable, body, rbrace_site)) in list(methods.items()):
329+
argnames = set()
330+
for (n, _) in inp:
331+
if n in argnames:
332+
report(EARGD(msite, n))
333+
bad_methods.add(name)
334+
if n != '_':
335+
argnames.add(n)
329336
for ancestor in direct_parents:
330337
coll = ancestor.member_declaration(name)
331338
if coll:

test/1.4/errors/T_EARGD.dml

+17
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,20 @@ device test;
99
/// ERROR EARGD
1010
method m(int x, int x) {
1111
}
12+
13+
template t {
14+
/// ERROR EARGD
15+
shared method m(int x, int x);
16+
/// ERROR EARGD
17+
shared method n(int x, int x) {}
18+
}
19+
20+
is t;
21+
22+
method init() {
23+
// Ensure that the bad methods do not become part of the device structure
24+
/// ERROR EREF
25+
this.m(1,1);
26+
/// ERROR EREF
27+
this.n(1,1);
28+
}

0 commit comments

Comments
 (0)