<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Arial,Helvetica,sans-serif'>
<p>Thanks! This is in line with what I was suspecting. However, why in the world does the compiler not warn in this case. This should be at least happening I would suppose?</p>
<div> </div>
Darius<br /><br />
<p>Vojtěch Čihák schreef op 28 okt '17:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">Overloading means that you have functions with the same name but different parameter (or param. list). You can have different return type for each parameter but you can never have the same parameters.</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">V.</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">______________________________________________________________<br /> > Od: Darius Blaszyk <dhkblaszyk@zeelandnet.nl><br /> > Komu: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org><br /> > Datum: 28.10.2017 22:58<br /> > Předmět: [fpc-pascal] Overloaded functions<br /> ></p>
Hi,<br /> <br /> I have a problem with overloaded functions. I defined these functions:<br /> function val_(name: string): string;<br /> function val_(name: string): boolean;<br /> function val_(name: string): integer;<br /> function val_(name: string): double;<br /> <br /> var<br /> res: boolean;<br /> begin<br /> res := val_(option_variable);<br /> end;<br /> <br /> I get the following error: Error: Incompatible types: got "ShortString" expected "Boolean". So for some reason the compiler is looking at the first function. The mode is objfpc and I turned ansistrings off. I tested by adding the overload modifier but without result. What else could I try or do? Or is overloading only allowed for different parameter lists?<br /> <br /> Rgds, Darius<br /> <br /> <br /> ----------<br /> <br /> _______________________________________________<br /> fpc-pascal maillist - fpc-pascal@lists.freepascal.org<br /> <a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" target="_blank" rel="noopener noreferrer">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a> <br />
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">_______________________________________________<br /> fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br /> <a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" target="_blank" rel="noopener noreferrer">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a></div>
</blockquote>
</body></html>