mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
WIP
This commit is contained in:
parent
f3dce67895
commit
1733f300bb
1 changed files with 14 additions and 12 deletions
|
@ -6,8 +6,7 @@ open import Luau.Type using (Type; nil; number; string; boolean; never; unknown;
|
||||||
¬function : Type
|
¬function : Type
|
||||||
¬function = number ∪ (string ∪ (nil ∪ boolean))
|
¬function = number ∪ (string ∪ (nil ∪ boolean))
|
||||||
|
|
||||||
-- Normalize
|
-- Unions and intersections of normalized types
|
||||||
normalize : Type → Type
|
|
||||||
_∪ᶠ_ : Type → Type → Type
|
_∪ᶠ_ : Type → Type → Type
|
||||||
_∩ᶠ_ : Type → Type → Type
|
_∩ᶠ_ : Type → Type → Type
|
||||||
_∪ⁿˢ_ : Type → Type → Type
|
_∪ⁿˢ_ : Type → Type → Type
|
||||||
|
@ -16,16 +15,6 @@ _∪ⁿ_ : Type → Type → Type
|
||||||
_∩ⁿ_ : Type → Type → Type
|
_∩ⁿ_ : Type → Type → Type
|
||||||
_⇒ᶠ_ : Type → Type → Type
|
_⇒ᶠ_ : Type → Type → Type
|
||||||
|
|
||||||
normalize nil = never ∪ nil
|
|
||||||
normalize (S ⇒ T) = (normalize S ⇒ᶠ normalize T)
|
|
||||||
normalize never = never
|
|
||||||
normalize unknown = unknown
|
|
||||||
normalize boolean = never ∪ boolean
|
|
||||||
normalize number = never ∪ number
|
|
||||||
normalize string = never ∪ string
|
|
||||||
normalize (S ∪ T) = normalize S ∪ⁿ normalize T
|
|
||||||
normalize (S ∩ T) = normalize S ∩ⁿ normalize T
|
|
||||||
|
|
||||||
-- Union of function types
|
-- Union of function types
|
||||||
never ∪ᶠ G = G
|
never ∪ᶠ G = G
|
||||||
F ∪ᶠ never = F
|
F ∪ᶠ never = F
|
||||||
|
@ -76,3 +65,16 @@ F ∪ⁿˢ T = F ∪ T
|
||||||
-- Functions between normalized types
|
-- Functions between normalized types
|
||||||
(never ⇒ᶠ T) = (never ⇒ unknown)
|
(never ⇒ᶠ T) = (never ⇒ unknown)
|
||||||
(S ⇒ᶠ T) = (S ⇒ T)
|
(S ⇒ᶠ T) = (S ⇒ T)
|
||||||
|
|
||||||
|
-- Normalize!
|
||||||
|
normalize : Type → Type
|
||||||
|
normalize nil = never ∪ nil
|
||||||
|
normalize (S ⇒ T) = (normalize S ⇒ᶠ normalize T)
|
||||||
|
normalize never = never
|
||||||
|
normalize unknown = unknown
|
||||||
|
normalize boolean = never ∪ boolean
|
||||||
|
normalize number = never ∪ number
|
||||||
|
normalize string = never ∪ string
|
||||||
|
normalize (S ∪ T) = normalize S ∪ⁿ normalize T
|
||||||
|
normalize (S ∩ T) = normalize S ∩ⁿ normalize T
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue