You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(* lib.sats *)#include"share/atspre_staload_libats_ML.hats"datatype Result(value:t@ype, error: t@ype) =| Ok of value
| Err of error
typedef UnexpectedError =
'{ actual = string
, expected = string
}
datatype Error =| Eof
| Unexpected of UnexpectedError
typedef Stream = list0(char)
typedef Parser(a: t@ype) =
'{ parser = (Stream) -<cloref1> Result((Stream, a), Error)
}
fun alpha(): Parser(char)
fun alpha_num(): Parser(char)
fun num(): Parser(char)
fun one_of(chars: string): Parser(char)
fun{a: t@ype}or(parser1: Parser(a), parser2: Parser(a)): Parser(a)
I've tried to reproduce the issue with a small example, but I was unable to do so, so I've simplified my example to a minimum.
Here's the error that is produced:
In file included from lib_dats.c:15:
lib_dats.c: Dans la fonction « _057_Tests_057_ATS_057_order_bug_057_lib_056_sats__alpha_num »:
lib_dats.c:1799:21: error: « PMVtmpltcstmat » non déclaré (première utilisation dans cette fonction)
ATSINSmove(tmpret1, PMVtmpltcstmat[0](or<S2Ecst(char_t0ype)>)(tmp2, tmp3)) ;
^~~~~~~~~~~~~~
/usr/lib/ats2-postiats-0.3.11/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: dans la définition de la macro « ATSINSmove »
#define ATSINSmove(tmp, val) (tmp = val)
^~~
lib_dats.c:1799:21: note: chaque identificateur non déclaré est rapporté une seule fois pour chaque fonction dans laquelle il apparaît
ATSINSmove(tmpret1, PMVtmpltcstmat[0](or<S2Ecst(char_t0ype)>)(tmp2, tmp3)) ;
^~~~~~~~~~~~~~
/usr/lib/ats2-postiats-0.3.11/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: dans la définition de la macro « ATSINSmove »
#define ATSINSmove(tmp, val) (tmp = val)
^~~
lib_dats.c:1799:39: error: « or » non déclaré (première utilisation dans cette fonction)
ATSINSmove(tmpret1, PMVtmpltcstmat[0](or<S2Ecst(char_t0ype)>)(tmp2, tmp3)) ;
^~
/usr/lib/ats2-postiats-0.3.11/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: dans la définition de la macro « ATSINSmove »
#define ATSINSmove(tmp, val) (tmp = val)
^~~
lib_dats.c:1799:42: warning: déclaration implicite de la fonction « S2Ecst » [-Wimplicit-function-declaration]
ATSINSmove(tmpret1, PMVtmpltcstmat[0](or<S2Ecst(char_t0ype)>)(tmp2, tmp3)) ;
^~~~~~
/usr/lib/ats2-postiats-0.3.11/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: dans la définition de la macro « ATSINSmove »
#define ATSINSmove(tmp, val) (tmp = val)
^~~
lib_dats.c:1799:49: error: « char_t0ype » non déclaré (première utilisation dans cette fonction); vouliez-vous utiliser « wchar_t » ?
ATSINSmove(tmpret1, PMVtmpltcstmat[0](or<S2Ecst(char_t0ype)>)(tmp2, tmp3)) ;
^~~~~~~~~~
/usr/lib/ats2-postiats-0.3.11/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: dans la définition de la macro « ATSINSmove »
#define ATSINSmove(tmp, val) (tmp = val)
^~~
lib_dats.c:1799:61: error: expected expression before « ) » token
ATSINSmove(tmpret1, PMVtmpltcstmat[0](or<S2Ecst(char_t0ype)>)(tmp2, tmp3)) ;
^
/usr/lib/ats2-postiats-0.3.11/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: dans la définition de la macro « ATSINSmove »
#define ATSINSmove(tmp, val) (tmp = val)
^~~
If I put the implement or before the call to or, the code compiles fine:
It is actually a very important feature. A template function can always be re-implemented. And lexical scoping is used to determine which implementation of the template is supposed to be used.
Ok, having an error reporting in ATS instead of in C (gcc) would be great to explain what is going on.
It seemed strange to me that function without generic parameters have a different behavior.
Hi.
Here's the code with the error:
and:
I've tried to reproduce the issue with a small example, but I was unable to do so, so I've simplified my example to a minimum.
Here's the error that is produced:
If I put the
implement or
before the call toor
, the code compiles fine:I believe this is a bug as this seems to work in other scenarios.
Thanks to fix the issue.
The text was updated successfully, but these errors were encountered: