1
+ # -----------------------------------------------------------------------
2
+ # This file is part of MoonScript
3
+ #
4
+ # MoonSript is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # MoonSript is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with MoonSript. If not, see <https://www.gnu.org/licenses/>.
16
+ #
17
+ # Copyright (C) 2025 Krisna Pranav, MoonScript Developers
18
+ # -----------------------------------------------------------------------
19
+
20
+ module MoonScript
21
+ class TypeChecker
22
+ def check (node : Ast ::Connect ) : Checkable
23
+ store =
24
+ ast.stores.find(& .name.value.== (node.store.value))
25
+
26
+ error! :connect_not_found_store do
27
+ block do
28
+ text " looking for the store"
29
+ bold node.store.value
30
+ text " but could not find it."
31
+ end
32
+
33
+ snippet node.store
34
+ end unless store
35
+
36
+ resolve store
37
+
38
+ node.keys.each do |key |
39
+ error! :connect_not_found_member do
40
+ block do
41
+ text " The entity"
42
+ bold %( "#{ key.name.value } ")
43
+ text " does not exists!"
44
+ end
45
+
46
+ snippet " The connect in question:" , node
47
+ end unless found = scope.resolve(key.name.value, store).try(& .node)
48
+
49
+ cache[key] =
50
+ resolve found
51
+
52
+ lookups[key] =
53
+ {found, store}
54
+ end
55
+
56
+ VOID
57
+ end
58
+ end
59
+ end
0 commit comments