You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
server allModuleNames externs initNamesEnv initEnv port =do
123
125
codegenRef <-IORef.newIORef Nothing
124
126
let makeActions = buildMakeActions codegenRef
127
+
let modNames =Set.fromList allModuleNames
125
128
let compile ::Text->IO (EitherError ([P.JSONError], JS))
126
129
compile input
127
130
|T.length input >20000=return$Left$OtherError"Please limit your input to 20000 characters"
@@ -134,20 +137,24 @@ server externs initNamesEnv initEnv port = do
134
137
(_, Left parserErrors) ->
135
138
return$Left$ toCompilerErrors parserErrors
136
139
137
-
(parserWarnings, Right m) |P.getModuleName m ==P.ModuleName"Main"->do
138
-
(makeResult, warnings) <-Make.runMake P.defaultOptions $Make.rebuildModule' makeActions initNamesEnv externs m
139
-
codegenResult <-IORef.readIORef codegenRef
140
-
return$case makeResult of
141
-
Left errors ->
142
-
Left$CompilerErrors$ toJsonErrors errors
143
-
Right _ |Just js <- codegenResult ->do
144
-
let ws = warnings <>CST.toMultipleWarnings "<file>" parserWarnings
145
-
Right (toJsonErrors ws, js)
146
-
Right _ ->
147
-
Left$OtherError"Failed to read the results of codegen."
148
-
149
-
(_, Right _) ->
150
-
return$Left$OtherError"The name of the main module should be Main."
140
+
(parserWarnings, Right m)
141
+
|Set.notMember (P.getModuleName m) modNames ->do
142
+
(makeResult, warnings) <-Make.runMake P.defaultOptions $Make.rebuildModule' makeActions initNamesEnv externs m
143
+
codegenResult <-IORef.readIORef codegenRef
144
+
return$case makeResult of
145
+
Left errors ->
146
+
Left$CompilerErrors$ toJsonErrors errors
147
+
Right _ |Just js <- codegenResult ->do
148
+
let ws = warnings <>CST.toMultipleWarnings "<file>" parserWarnings
149
+
Right (toJsonErrors ws, js)
150
+
Right _ ->
151
+
Left$OtherError"Failed to read the results of codegen."
152
+
153
+
|otherwise->do
154
+
let
155
+
modName =N.runModuleName $P.getModuleName m
156
+
return$Left$OtherError$
157
+
"The name of the module you defined "<> modName <>" clashes with another module in the package set. Rename the module to something else (e.g. 'Main')."
0 commit comments