aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc
diff options
context:
space:
mode:
Diffstat (limited to 'new-luxc/source/luxc')
-rw-r--r--new-luxc/source/luxc/lang/module.lux24
1 files changed, 17 insertions, 7 deletions
diff --git a/new-luxc/source/luxc/lang/module.lux b/new-luxc/source/luxc/lang/module.lux
index 62e20fa9a..58bf94571 100644
--- a/new-luxc/source/luxc/lang/module.lux
+++ b/new-luxc/source/luxc/lang/module.lux
@@ -19,6 +19,7 @@
(exception: #export Cannot-Define-More-Than-Once)
(exception: #export Cannot-Define-In-Unknown-Module)
(exception: #export Can-Only-Change-State-Of-Active-Module)
+(exception: #export Cannot-Set-Module-Annotations-More-Than-Once)
(def: (new-module hash)
(-> Nat Module)
@@ -28,18 +29,27 @@
#.imports (list)
#.tags (list)
#.types (list)
- #.module-annotations (' {})
+ #.module-annotations #.None
#.module-state #.Active})
(def: #export (set-annotations annotations)
(-> Code (Meta Unit))
(do macro.Monad<Meta>
- [self macro.current-module-name]
- (function [compiler]
- (#e.Success [(update@ #.modules
- (&.pl-update self (set@ #.module-annotations annotations))
- compiler)
- []]))))
+ [self-name macro.current-module-name
+ self macro.current-module]
+ (case (get@ #.module-annotations self)
+ #.None
+ (function [compiler]
+ (#e.Success [(update@ #.modules
+ (&.pl-put self-name (set@ #.module-annotations (#.Some annotations) self))
+ compiler)
+ []]))
+
+ (#.Some old)
+ (macro.fail (Cannot-Set-Module-Annotations-More-Than-Once
+ (format " Module: " self-name "\n"
+ "Old annotations: " (%code old) "\n"
+ "New annotations: " (%code annotations) "\n"))))))
(def: #export (import module)
(-> Text (Meta Unit))