@@ -232,7 +232,34 @@ extends Importer:
232232 term(rhs)
233233 case tree @ App (lhs, rhs) =>
234234 val sym = FlowSymbol (" ‹app-res›" , nextUid)
235- Term .App (term(lhs), term(rhs))(tree, sym)
235+ val lt = term(lhs)
236+ val rt = term(rhs)
237+
238+ // Check if module arguments match module parameters
239+ val args = rt match
240+ case Term .Tup (fields) => S (fields)
241+ case _ => N
242+ val params = lt.symbol
243+ .collect:
244+ case sym : BlockMemberSymbol => sym.trmTree
245+ .flatten
246+ .collect:
247+ case td : TermDef => td.paramLists.headOption
248+ .flatten
249+ for
250+ (args, params) <- (args zip params)
251+ (arg, param) <- (args zip params.fields)
252+ do
253+ val argMod = arg.flags.mod
254+ val paramMod = param match
255+ case Tree .TypeDef (Mod , _, N , N ) => true
256+ case _ => false
257+ if argMod && ! paramMod then raise :
258+ ErrorReport :
259+ msg " Only module parameters may receive module arguments (values). " ->
260+ arg.toLoc :: Nil
261+
262+ Term .App (lt, rt)(tree, sym)
236263 case Sel (pre, nme) =>
237264 val preTrm = term(pre)
238265 val sym = resolveField(nme, preTrm.symbol, nme)
@@ -329,9 +356,10 @@ extends Importer:
329356 Fld (FldFlags .empty, term(lhs), S (term(rhs)))
330357 case _ =>
331358 val t = term(tree)
332- t.symbol.flatMap(_.asMod) match
333- case S (_) => Fld (FldFlags .empty.copy(mod = true ), t, N )
334- case N => Fld (FldFlags .empty, t, N )
359+ val flags = FldFlags .empty
360+ if ModuleChecker .evalsToModule(t)
361+ then Fld (flags.copy(mod = true ), t, N )
362+ else Fld (flags, t, N )
335363
336364 def unit : Term .Lit = Term .Lit (UnitLit (true ))
337365
0 commit comments