@@ -740,6 +740,23 @@ pub enum AnalyzerError {
740740 token_source : TokenSource ,
741741 } ,
742742
743+ #[ diagnostic(
744+ severity( Warning ) ,
745+ code( mutable_for_bound) ,
746+ help( "move the assignment outside the loop or iterate over a separate, stable bound; this will become an error in a future release" ) ,
747+ url( "https://doc.veryl-lang.org/book/07_appendix/02_semantic_error.html#{}" , self . code( ) . unwrap( ) )
748+ ) ]
749+ #[ error(
750+ "for-loop continuation bound is modified by the loop body, so backends may execute different iteration counts"
751+ ) ]
752+ MutableForBound {
753+ #[ source_code]
754+ input : MultiSources ,
755+ #[ label( "Warning location" ) ]
756+ error_location : SourceSpan ,
757+ token_source : TokenSource ,
758+ } ,
759+
743760 #[ diagnostic(
744761 severity( Error ) ,
745762 code( invalid_for_step) ,
@@ -2076,6 +2093,7 @@ impl AnalyzerError {
20762093 AnalyzerError :: MissingTri { input, .. } => input,
20772094 AnalyzerError :: MixedFunctionArgument { input, .. } => input,
20782095 AnalyzerError :: MixedStructUnionMember { input, .. } => input,
2096+ AnalyzerError :: MutableForBound { input, .. } => input,
20792097 AnalyzerError :: MultipleAssignment { input, .. } => input,
20802098 AnalyzerError :: MultipleDefault { input, .. } => input,
20812099 AnalyzerError :: NonConstantSelectWidth { input, .. } => input,
@@ -2197,6 +2215,7 @@ impl AnalyzerError {
21972215 AnalyzerError :: MissingTri { token_source, .. } => * token_source,
21982216 AnalyzerError :: MixedFunctionArgument { token_source, .. } => * token_source,
21992217 AnalyzerError :: MixedStructUnionMember { token_source, .. } => * token_source,
2218+ AnalyzerError :: MutableForBound { token_source, .. } => * token_source,
22002219 AnalyzerError :: MultipleAssignment { token_source, .. } => * token_source,
22012220 AnalyzerError :: MultipleDefault { token_source, .. } => * token_source,
22022221 AnalyzerError :: PrivateMember { token_source, .. } => * token_source,
@@ -2638,6 +2657,13 @@ impl AnalyzerError {
26382657 token_source : token. source ( ) ,
26392658 }
26402659 }
2660+ pub fn mutable_for_bound ( token : & TokenRange ) -> Self {
2661+ AnalyzerError :: MutableForBound {
2662+ input : source ( token) ,
2663+ error_location : token. into ( ) ,
2664+ token_source : token. source ( ) ,
2665+ }
2666+ }
26412667 pub fn invalid_for_step ( cause : InvalidForStepKind , token : & TokenRange ) -> Self {
26422668 AnalyzerError :: InvalidForStep {
26432669 cause,
0 commit comments