Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
why3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Why3
why3
Commits
d89815f1
Commit
d89815f1
authored
14 years ago
by
Jean-Christophe Filliâtre
Browse files
Options
Downloads
Patches
Plain Diff
programs: fixed detection of polymorphic mutable values
parent
0656a717
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bench/programs/bad-typing/polyref2.mlw
+0
-5
0 additions, 5 deletions
bench/programs/bad-typing/polyref2.mlw
src/programs/pgm_typing.ml
+17
-9
17 additions, 9 deletions
src/programs/pgm_typing.ml
with
17 additions
and
14 deletions
bench/programs/bad-typing/polyref2.mlw
deleted
100644 → 0
+
0
−
5
View file @
0656a717
module M
parameter c : 'a
end
This diff is collapsed.
Click to expand it.
src/programs/pgm_typing.ml
+
17
−
9
View file @
d89815f1
...
@@ -1798,17 +1798,25 @@ let add_exception loc x ty uc =
...
@@ -1798,17 +1798,25 @@ let add_exception loc x ty uc =
with
ClashSymbol
_
->
with
ClashSymbol
_
->
errorm
~
loc
"clash with previous exception %s"
x
errorm
~
loc
"clash with previous exception %s"
x
let
rec
polymorphic_pure_type
ty
=
match
ty
.
ty_node
with
(* [cannot_be_generalized_ty ty] returns a pair (t, m) where
|
Ty
.
Tyvar
_
->
true
[t = true] iff [ty] contains a type variable
|
Ty
.
Tyapp
(
_
,
tyl
)
->
List
.
exists
polymorphic_pure_type
tyl
[m = true] iff [ty] contains a polymorphic mutable type *)
let
rec
cannot_be_generalized_ty
ty
=
match
ty
.
ty_node
with
|
Ty
.
Tyapp
(
ts
,
tyl
)
->
let
n
=
(
get_mtsymbol
ts
)
.
mt_regions
in
let
t
,
m
=
List
.
fold_left
(
fun
(
acct
,
accm
)
ty
->
let
t
,
m
=
cannot_be_generalized_ty
ty
in
acct
||
t
,
accm
||
m
)
(
false
,
false
)
(
Util
.
chop
n
tyl
)
in
t
,
m
||
n
>
0
&&
t
|
Ty
.
Tyvar
_
->
true
,
false
let
cannot_be_generalized
=
function
let
cannot_be_generalized
=
function
|
Tpure
{
ty_node
=
Ty
.
Tyapp
(
ts
,
tyl
)
}
when
is_mutable_ts
ts
->
|
Tpure
ty
->
let
_
,
m
=
cannot_be_generalized_ty
ty
in
m
List
.
for_all
polymorphic_pure_type
tyl
|
Tarrow
_
->
false
|
Tpure
{
ty_node
=
Ty
.
Tyvar
_
}
->
true
|
Tpure
_
|
Tarrow
_
->
false
let
check_type_vars
~
loc
vars
ty
=
let
check_type_vars
~
loc
vars
ty
=
let
h
=
Htv
.
create
17
in
let
h
=
Htv
.
create
17
in
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment