Open myitcv opened 2 years ago
Probably another issue, but I have thought for a while that files without a package clause that co-exist with files with a package clause should result in an error, because it's a very common mistake to make.
@rogpeppe: if one looks at the original intent, then one could argue it should be allowed.
However, we could indeed require an explicit package _
or something in case such files need to coexist with package files.
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
What did you expect to see?
Subject to the suggestion below, a passing test.
What did you see instead?
This conversation started off the back of a problem someone raised in Slack.
The issue today is that
cue eval
(not specific toeval
) succeeds becausecmd/cue
sees the syntax error iny.cue
and so ignores the file. However, it's hopefully obvious that the user intended the file to belong topackage x
.Whilst an LSP implementation (#142) will likely help to prevent such syntax errors in the first place, we can't rule them out and it doesn't seem ideal that files with syntax errors silently get dropped.
Following a discussion with @rogpeppe, we believe that a better heuristic here would be to raise syntax errors unless it is known that a file does not belong to the set of packages specified as input to
cmd/cue
(hence the expectation in the testscript test above).Under this suggestion, given a
cmd/cue
input packagep
, syntax errors would therefore be raised for:package p
clause that contain syntax errorsBut syntax errors would not be raised for:
package p
but are ignored by virtue of an unsatisfied build attribute