Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug sur la compilation des or-patterns ? #2733

Closed
vicuna opened this issue Mar 26, 2001 · 2 comments
Closed

bug sur la compilation des or-patterns ? #2733

vicuna opened this issue Mar 26, 2001 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Mar 26, 2001

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.

Emmanuel Coquery

e-mail: Emmanuel.Coquery@inria.fr

@vicuna
Copy link
Author

vicuna commented Mar 30, 2001

Comment author: administrator

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.

Merci d'avoir signalé le bug.

--Luc

@vicuna
Copy link
Author

vicuna commented Mar 30, 2001

Comment author: administrator

Fixed by Luc 30-03-2001.

@vicuna vicuna closed this as completed Mar 30, 2001
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant