Opened 12 years ago

Closed 12 years ago

#1808 closed defect (fixed)

Reject multiple elements in class

Reported by: adabe588@… Owned by: somebody
Priority: critical Milestone: 1.9.0
Component: Parser Version: trunk
Keywords: Cc:

Description

I'm not sure if function overloading is supported or not. I suppose that with the package system there is not much point to having it, but if overloading is attempted no errors occur but all functions are not called properly either.

package O

function f
  input Integer i;
algorithm
  print("foo");
end f;

function f
  input String s;
algorithm
  print(s);
end f;

end O;
setCommandLineOptions({"+d=rml,noevalfunc,failtrace","+g=MetaModelica"});
loadFile("Overloading.mo");

O.f(1);
O.f("x");
O.f(2);

Expected: duplicate function definition error, or

{true,true}
{true}
foo
x
foo

Actual:

{true,true}
true

x

Change History (3)

comment:1 by Martin Sjölund, 12 years ago

[a.mo:9:1-13:6:writable] Error: An element with name f is already declared in this scope.

I will see if this check is missing for loadFile API

comment:2 by Martin Sjölund, 12 years ago

Also, overloading looks like function abs = overload(OpenModelica.Internal.intAbs, OpenModelica.Internal.realAbs);
From: abs.html

comment:3 by Martin Sjölund, 12 years ago

Component: BackendParser
Priority: minorcritical
Resolution: fixed
Status: newclosed
Summary: Function overloading doesn't work properly or fails silentlyReject multiple elements in class

Testcase added, fixed in r12924.

Note: See TracTickets for help on using tickets.