Skip to content

Commit

Permalink
Add test cases from issue chapel-lang#19352
Browse files Browse the repository at this point in the history
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
  • Loading branch information
mppf committed Mar 28, 2022
1 parent 1f9d925 commit cc86e72
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/modules/shadowing/issue-19352-1.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Library {
record rec {
proc method() { writeln("Library's rec.method()"); }
}
}


module LibraryPlus {
import Library;
import Library.rec;

proc rec.method() { writeln("LibraryPlus's rec.method()"); }
}

// Case 1
module Program {
import Library;
proc main() {
import LibraryPlus.rec; // does this make LibraryPlus.rec.method "closer" ?
var r = new Library.rec();
r.method(); // currently: ambiguity error
}
}
4 changes: 4 additions & 0 deletions test/modules/shadowing/issue-19352-1.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
issue-19352-1.chpl:18: In function 'main':
issue-19352-1.chpl:21: error: ambiguous call 'rec.method()'
issue-19352-1.chpl:3: note: candidates are: rec.method()
issue-19352-1.chpl:12: note: rec.method()
18 changes: 18 additions & 0 deletions test/modules/shadowing/issue-19352-2a.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Library {
record rec {
proc method() { writeln("Library's rec.method()"); }
}
}

// Case 2a
module Program {
import Library;
import Library.rec; // Should this bring in the methods as if defined here?

proc rec.method() { writeln("Program's rec.method()"); }

proc main() {
var r = new Library.rec();
r.method(); // currently outputs: Program's rec.method()
}
}
4 changes: 4 additions & 0 deletions test/modules/shadowing/issue-19352-2a.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
issue-19352-2a.chpl:14: In function 'main':
issue-19352-2a.chpl:16: error: ambiguous call 'rec.method()'
issue-19352-2a.chpl:3: note: candidates are: rec.method()
issue-19352-2a.chpl:12: note: rec.method()
18 changes: 18 additions & 0 deletions test/modules/shadowing/issue-19352-2b.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Library {
record rec {
proc method() { writeln("Library's rec.method()"); }
}
}

// Case 2b
module Program {
import Library; // Should this bring in the methods
// on types defined in Library as if defined here?

proc (Library.rec).method() { writeln("Program's rec.method()"); }

proc main() {
var r = new Library.rec();
r.method(); // currently outputs: Program's rec.method()
}
}
4 changes: 4 additions & 0 deletions test/modules/shadowing/issue-19352-2b.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
issue-19352-2b.chpl:14: In function 'main':
issue-19352-2b.chpl:16: error: ambiguous call 'rec.method()'
issue-19352-2b.chpl:3: note: candidates are: rec.method()
issue-19352-2b.chpl:12: note: (Library.rec).method()
26 changes: 26 additions & 0 deletions test/modules/shadowing/issue-19352-3.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module Library {
record rec {
proc method() { writeln("Library's rec.method()"); }
}
}


module LibraryPlus {
import Library;
import Library.rec;

proc rec.method() { writeln("LibraryPlus's rec.method()"); }
}

// Case 3
module Program {
public import Library;
public use LibraryPlus; // should LibraryPlus.rec.method now shadow Library.rec.method?

proc main() {
var r = new Library.rec();
r.method(); // currently:
// without PR #19306, ambiguity error
// with PR #19306, outputs LibraryPlus's rec.method()
}
}
4 changes: 4 additions & 0 deletions test/modules/shadowing/issue-19352-3.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
issue-19352-3.chpl:20: In function 'main':
issue-19352-3.chpl:22: error: ambiguous call 'rec.method()'
issue-19352-3.chpl:3: note: candidates are: rec.method()
issue-19352-3.chpl:12: note: rec.method()

0 comments on commit cc86e72

Please sign in to comment.