Hello DFINITY engineering team and community,
I’ve been developing a large Motoko-based project on the Internet Computer with complex backend modules. For several days, every build has failed due to persistent backend compilation errors specifically originating from these files:
-
authorization/access-control.mo -
user-approval/approval.mo
These two modules appear to reinitialize OrderedMap.Make<Principal> inside multiple functions instead of reusing the shared maps declared in the state (AccessControlState and UserApprovalState). This leads to constant type mismatches, scoping conflicts, and failed compilation when attempting to build the actor TimeIsMoney. The compiler throws errors like “type mismatch,” “field not found,” or “cannot update immutable structure.”
What should happen:
Each module should reuse the already initialized maps in the shared state, not declare new ones inside each function. For example, the functions should update or read from state.userRoles or state.approvalStatus directly rather than creating local maps with new OrderedMap.Make calls.
Proposed fix direction:
-
Remove redundant
let principalMap = OrderedMap.Make<Principal>(Principal.compare)inside each function. -
Update all mutations to use
state.userRoles := OrderedMap.put(state.userRoles, user, role)or similar shared references. -
Ensure maps in state are declared mutable and accessed consistently across functions.
-
Validate that
orderedMap.putoperations reference the shared map instance to maintain compiler consistency.
Even though the frontend builds successfully, the backend cannot deploy until these Motoko logic errors are corrected. I’ve attempted multiple rebuilds without success.
Could someone from the DFINITY team please review this issue and confirm the correct pattern for updating shared OrderedMap state inside Motoko modules?
Any structural code suggestions or examples from official best practices would be deeply appreciated.
Thank you,
Travis Schaub
Founder – TIME (Time Is Money Enterprises LLC)





