Skip to content

Commit

Permalink
Modifications in response to review
Browse files Browse the repository at this point in the history
Added duplicate_no_arg test
  • Loading branch information
softmattertheory committed Jun 1, 2024
1 parent b611445 commit 4af6890
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions help/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Note that optional and variadic parameters are not typed.
# Multiple dispatch
[tagmultiple]: # (multiple)
[tagdispatch]: # (dispatch)
[tagmultipledispatch]: # (multipledispatch)

Morpho supports *multiple dispatch*, whereby you can define several implementations of a function that accept different types:

Expand Down
12 changes: 12 additions & 0 deletions test/types/multiple_dispatch/duplicate_no_arg.morpho
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Duplicate implementations with no arguments.

fn f() {
return 0
}

fn f() {
return 1
}

print f()
// expect error 'MltplDisptchAmbg'
1 change: 0 additions & 1 deletion test/types/multiple_dispatch/duplicate_no_type.morpho
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Duplicate implementations with one argument no Type annotations.
// This one currently segfaults due to an infinite loop.

fn f(x) {
return 0
Expand Down
1 change: 0 additions & 1 deletion test/types/multiple_dispatch/namespace_for_new.morpho
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ fn f(Matrix a) {

}

// Do we want this to be a new implementation for the namespace function, or this is not intended / allowed?
f(Matrix(2,2))
// expect: [ 2, 2 ]

0 comments on commit 4af6890

Please sign in to comment.