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
Original bug ID: 326 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Bonjour,
j'obtiens un resultat curieux en utilisant un or-pattern.
je n'ai pas réussi a reproduire dans un fichier simple, je vous envoie
donc le code de la fonction dans laquelle j'ai localisé le probleme.
----------------------------- debut ----------------------------------
let handle_module data q =
print_endline (Prolog_ast.to_string q);
flush stdout;
match q with
| Funct("module",[modu;preds],,)
| Funct("module",[modu;preds;],,_) ->
begin try
print_endline (Prolog_ast.to_string q);
flush stdout;
let module_name =
(Term_utils.Convert.to_atom
(fun _ ->
wrong_argument "module" data modu;
failwith "")
modu)
and predicates_list =
Term_utils.Convert.to_a_list
(Term_utils.Convert.to_funct
(fun t -> begin
print_endline (Prolog_ast.to_string t);
exit 1
(*
wrong_argument "module" data modu;
failwith ""
end*)
end
)
)
preds
in
print_endline ("module : " ^ module_name);
Transform.set_defining data.infos
{ Transform.name = module_name ;
Transform.predicates = Some predicates_list };
true
with Failure _ -> false
end
| _ -> false
------------------------------- fin ---------------------------------
en utilisant cette fonction j'obtiens le resultat suivant:
Le bug signalé par toi est corrigé et la correction commise dans les
sources de développement.
En attendant le lacher de ces sources, un moyen de contourner le bug
est de ne pas utiliser à la fois ocamlc et deux variables ou plus dans
les orpats.
Original bug ID: 326
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Bonjour,
j'obtiens un resultat curieux en utilisant un or-pattern.
je n'ai pas réussi a reproduire dans un fichier simple, je vous envoie
donc le code de la fonction dans laquelle j'ai localisé le probleme.
----------------------------- debut ----------------------------------
let handle_module data q =
print_endline (Prolog_ast.to_string q);
flush stdout;
match q with
| Funct("module",[modu;preds],,)
| Funct("module",[modu;preds;],,_) ->
begin try
print_endline (Prolog_ast.to_string q);
flush stdout;
let module_name =
(Term_utils.Convert.to_atom
(fun _ ->
wrong_argument "module" data modu;
failwith "")
modu)
and predicates_list =
Term_utils.Convert.to_a_list
(Term_utils.Convert.to_funct
(fun t -> begin
print_endline (Prolog_ast.to_string t);
exit 1
(*
wrong_argument "module" data modu;
failwith ""
end*)
end
)
)
preds
in
print_endline ("module : " ^ module_name);
Transform.set_defining data.infos
{ Transform.name = module_name ;
Transform.predicates = Some predicates_list };
true
with Failure _ -> false
end
| _ -> false
------------------------------- fin ---------------------------------
en utilisant cette fonction j'obtiens le resultat suivant:
--debut--
[ coquery @ monbazillac ~/monbazillac/DEVEL/tclp ]
$ ./tclp tests/simple.pl
##################################################
"tests/simple.pl" :
module(simple, .(/(grand_pere, 2), .(/(grand_mere, 2), .(/(parent, 2),
.(/(pere, 2), .(/(mere, 2), []))))))
simple
Fatal error: uncaught exception Invalid_argument("String.create")
--fin--
"module(...)" correspond au premier affichage de q et "simple" au
deuxieme.
en commentant une partie du pattern :
...
match q with
| Funct("module",[modu;preds],,)
(| Funct("module",[modu;preds;],,_)) ->
begin try
print_endline (Prolog_ast.to_string q);
flush stdout;
...
on obtient :
--debut--
[ coquery @ monbazillac ~/monbazillac/DEVEL/tclp ]
$ ./tclp tests/simple.pl
##################################################
"tests/simple.pl" :
module(simple, .(/(grand_pere, 2), .(/(grand_mere, 2), .(/(parent, 2),
.(/(pere, 2), .(/(mere, 2), []))))))
module(simple, .(/(grand_pere, 2), .(/(grand_mere, 2), .(/(parent, 2),
.(/(pere, 2), .(/(mere, 2), []))))))
File: "/home/monbazillac/coquery/DEVEL/tclp/tests/simple.pl", line 10,
characters 5-8functor ``jean/0'' was not declared
module : simple
after reading
pere(jean, fred).
pere(fred, alain).
--fin--
le comportement du programme est conforme à ce que j'attends.
ici les deux affichages de q sont semblables.
e-mail: Emmanuel.Coquery@inria.fr
The text was updated successfully, but these errors were encountered: