From: "Ricardo Brandão" <rbrandao.br@gmail.com>
Subject: Doubts on Function Overloading
Date: Mon, 17 Jun 2019 15:31:45 -0700 (PDT)
Date: 2019-06-17T15:31:45-07:00 [thread overview]
Message-ID: <c6d200f3-5582-4947-a381-0dcd20268b9f@googlegroups.com> (raw)
Hi,
In the very first program I tried after finish the tutorial from Learn.Adacore.com I got some compile errors related to Overloading.
My idea was verify how Ada deal with JSON. So, I found out this program [1].
I created a project on GPS, included GnatCool as dependence, and when I tried to compile, I got the error:
λ gprbuild.exe main.adb
using project file adajson.gpr
Compile
[Ada] main.adb
main.adb:16:11: ambiguous call to "Set_Field"
main.adb:16:11: possible interpretation at gnatcoll-json.ads:317
main.adb:16:11: possible interpretation at gnatcoll-json.ads:323
main.adb:30:11: ambiguous call to "Set_Field"
main.adb:30:11: possible interpretation at gnatcoll-json.ads:317
main.adb:30:11: possible interpretation at gnatcoll-json.ads:323
gprbuild: *** compilation phase failed
The source code is:
13 Penguin.Set_Field (Field_Name => "name",
14 Field => "Linux");
15
16 Penguin.Set_Field (Field_Name => "born",
17 Field => 1992);
28 Penguin := Read (JSON_String, "json.errors");
29
30 Penguin.Set_Field (Field_Name => "born",
31 Field => 1986);
The source code of gnatcool-json.ads cited on error:
317 procedure Set_Field
318 (Val : JSON_Value;
319 Field_Name : UTF8_String;
320 Field : Integer)
321 with Pre => Val.Kind = JSON_Object_Type;
322
323 procedure Set_Field
324 (Val : JSON_Value;
325 Field_Name : UTF8_String;
326 Field : Long_Integer)
327 with Pre => Val.Kind = JSON_Object_Type;
If I changed 1992 to "1992" on line 16, and 1986 to "1986" on line 30, the program compile ok.
Why compile didn't resolve correctly, as stated here [2]?
Thanks
[1] https://rosettacode.org/wiki/JSON#Ada
[2] https://learn.adacore.com/books/Ada_For_The_CPP_Java_Developer/chapters/06_Functions_and_Procedures.html?#overloading
--
Ricardo Brandão
next reply other threads:[~2019-06-17 22:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 22:31 Ricardo Brandão [this message]
2019-06-17 23:15 ` Doubts on Function Overloading Keith Thompson
2019-06-18 1:03 ` Ricardo Brandão
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox