False positives for cyclic module dependency breaks autocompletion

I have the context-aware autocompletion beta enabled, and while it was very beneficial in the long term there’s a strange issue where the script analysis would warn me about cyclic module dependency in most of the back-end ModuleScripts I wrote. Most of the modules that the IDE had mentioned do not even recursively call the following target module. The warning at first seemed small and oblivious, but I started to experience a concerning issue where some modules refuse to autocomplete which slowed my workflow, and I discovered that this issue was the source of the problem.

It is unfixable with --!nolint, --!nocheck removes the warning but it removes the benefits of Luau’s type checking system which only further degrades my workflow. The best workaround was wrapping the require function with two parentheses (require)(TARGET_PATH) which not only looks ugly but also ruins require's typechecking.

7 Likes

I’m bumping this year-old bug report because this didn’t get any attention AND because this bug is extremely annoying.

2 Likes

I’ve misphrased this bug report as the main issue was really just typechecking issues and my code still counts as cyclic module dependency although at that time I didn’t knew what the pattern was about.

The typechecking issue is actually documented on the Luau website, so I think this issue wasn’t particularly fixable:

image

1 Like

Unfortunately, that doesn’t fix the autocomplete though.

Could you at least give a reproduceable example of this occurring for engineers to investigate? This warning should only be popping up if you’re requiring another module that requires itself, so if it’s triggering for no reason, you should give an example of it happening.

1 Like

@WheretIB you mentioned you need a repro in the other thread, don’t want to veer off topic on that thread so I’ll post a repro. It’s obviously a very artificial example but I can post use cases if need be. There are some scripts in the workspace, both modules have the cyclic dependency warning but do not error at runtime.
image

falseCyclicDependency.rbxl (45.8 KB)

I now see what you mean, you refer to cycles that are not erroring at runtime as ‘false cycles’.

Analysis is performed statically, so this is not a false positive, types cannot be resolved in cycles.

To avoid the error, use require(a.b.c) :: any for one of the requires, I would suggest for the one that’s performed in a local function.

This is not going to be fixed.

1 Like

its really annoying that its not getting fixed. it will gonna boil my head fixing up false cyclic dependencies and luau autocomplete