Solving compiler error

26 views
Skip to first unread message

Dambaev Alexander

unread,
Aug 30, 2020, 9:47:58 PM8/30/20
to ats-lan...@googlegroups.com
Hi
Usually, I am able to parse and solve compiler errors, but now I need help:

```
  macdef GSIGNAL_CANCELLED = $extval( $GLIB.gsignal, "cancelled")
  fn foo( p: $GLIB.gpointer): void = ()
  val p = $GLIB.gpointer the_null_ptr
  prval _ = $showtype p
  val _ = $GLIB.g_signal_connect( cancellable, GSIGNAL_CANCELLED, $GLIB.G_CALLBACK(foo), p)
}
```

I get:

```
**SHOWTYPE[UP]**(/data/devel/cacaoweb/folders/libfm/base/DATS/folders.dats: 664(line=31, offs=23) -- 665(line=31, offs=24)): S2Ecst(gpointer): S2RTbas(S2RTBASimp(0; type))
/data/devel/cacaoweb/folders/libfm/base/DATS/folders.dats: 755(line=32, offs=90) -- 756(line=32, offs=91): error(3): the dynamic expression cannot be assigned the type [S2Ecst(gpointer)].
/data/devel/cacaoweb/folders/libfm/base/DATS/folders.dats: 755(line=32, offs=90) -- 756(line=32, offs=91): error(3): mismatch of static terms (tyleq):
The actual term is: S2Ecst(gpointer)
The needed term is: S2Ecst(gpointer)
```

Kiwamu Okabe

unread,
Aug 30, 2020, 9:55:09 PM8/30/20
to ats-lang-users
Dear Dambaev,

On Mon, Aug 31, 2020 at 10:47 AM Dambaev Alexander
<ice.r...@gmail.com> wrote:
> Usually, I am able to parse and solve compiler errors, but now I need help:

I think you are the best person to write Wiki page about $showtype:

> https://github.com/githwxi/ATS-Postiats/wiki
> * Debug: with assertloc, $showtype and GDB.

I'm so happy if you write a show article about $showtype on the Wiki.
Because I often forget the usage.

Best regards,
--
Kiwamu Okabe at METASEPI DESIGN

Hongwei Xi

unread,
Aug 30, 2020, 10:03:31 PM8/30/20
to ats-lan...@googlegroups.com
This means that gpointer is declared more than once in your code.
You need to check various 'staload' declarations in your code.

--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KxgmRqw9vsZKdTAh6ygegsEKb8mQhPgN9zXepGAR8QJOg%40mail.gmail.com.

Dambaev Alexander

unread,
Aug 31, 2020, 5:30:52 AM8/31/20
to ats-lan...@googlegroups.com
Kiwamu: wow, thanks for your trust, but after my quick view of your wiki page http://jats-ug.metasepi.org/doc/ATS2/ATS_Foundations/showtype.html and at the moment, I don't think, that I can add much more to it

Hongwei: thanks, you are right. glib's bindings provide 2 separate SATS files: glib.sats and glib-object.sats, so I created a sats file, in which I had included those 2 SATS files with '#include' pragma and used this one sats file for staloading. I wanted to get this:
```main.dats
staload GLIB="glib-ext.sats"
(* $GLIB.glib1 available here *)
(* $GLIB.glib2 available here *)
```
```glib-ext.sats
#include "contrib/glib/SATS/glib.sats"
#include "contrib/glib/SATS/glib-object.sats" (* staloads glib.sats *)
```
```contrib/glib/SATS/glib.sats
fn glib1():void
```
```contrib/glib/SATS/glib-object.sats
fn glib2():void
```

 So for now I have to staload them both in all modules, in which I need to use declarations from both. As far as I understand, there is no other way to achieve the same case without using #include pragma, am I right?

Other than that, is it ok for compiler to not to throw an error of multiple declarations of gpointer?

Hongwei Xi

unread,
Aug 31, 2020, 9:07:37 AM8/31/20
to ats-lan...@googlegroups.com
'#include' means copy/paste. It is not meant to be used
in the following manner:

```glib-ext.sats
#include "contrib/glib/SATS/glib.sats"
#include "contrib/glib/SATS/glib-object.sats" (* staloads glib.sats *)
```

You can create glib-ext.hats containing the following lines:

#staload "contrib/glib/SATS/glib.sats"
#staload "contrib/glib/SATS/glib-object.sats" (* staloads glib.sats *)

Then add the following line

#include "glib-ext.hats"

This allows you to staload both glib.sats and glib-object.sats

Here is a real example:


By the way, '#staload' is idempotent. Staloading a file multiple times causes NO problems:

#staload "contrib/glib/SATS/glib.sats"
#staload "contrib/glib/SATS/glib.sats"



--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages