Bugfix var local name#44
Conversation
|
it's good practice to extend the local name unit test with a few cases that test the span feature. |
|
This is an interesting solution, so basically if you are targeting a span, you create a sub-sequence on-the-fly so that transformations may treat is as a regular sequence node without explicit treatment. Note that this is not how we programmed similar transformations, see |
| end else begin | ||
| let (span_instrs, _instrs_after) = Mlist.split ~left_bias:false stop instrs in | ||
| let (_instrs_before, span_instrs) = Mlist.split ~left_bias:true start span_instrs in | ||
| let t_seq = trm_seq_nobrace ?result span_instrs in |
There was a problem hiding this comment.
In the end I did not modify to trm_seq_nobrace.
The No_brace modules asks for any nobrace sequence to be wrapped with a Nobrace_transfo.remove_after, which would be difficult in this situation, since this function is called for its output.
To be more precise, taking the unittest I wrote as an example, I would get an execution failure from Nobrace.current, because there is no live 'id' to use as a Nobrace annotation.
For me to be able to wrap with Nobrace_transfo.remove_after, I would need a 'unit -> unit' function, this means that I would need to encapsulate many function calls inside, which I believe is not a good idea.
There was a problem hiding this comment.
then you should try a unit test where you call the transformations on a subsequence containing an allocation, which probably won't work:
/* @target-begin */
int a = 0;
b++;
/* @target-end */
a++;
in this case it seems like creating sub-sequences on-the-fly during target resolution, although tempting because unifying APIs, might not be the way to go.
| Seq_helper.update_span_helper span t (fun tl -> [Trm (aux (trm_seq tl))]) | ||
| update_span_helper span t (fun tl -> [Trm (aux (trm_seq tl))]) |
There was a problem hiding this comment.
One could also consider keeping it qualified but short as in Seq_helper.update_span. In general, I think our current codebase is doing too much module opening and namespace flattening.
There was a problem hiding this comment.
I don't think I understand your point? Do you mean by that that function names are too long? You are right that we could for example change from Seq_helper.update_span_helper to Seq_helper.update_span, as it would not change the meaning of the function's name.
There was a problem hiding this comment.
I mean that we use ad-hoc prefixes like trm_add instead of nice modules like Trm.add that act as prefixes just as well.
| if span.start >= span.stop then begin | ||
| t_seq |
There was a problem hiding this comment.
I think part of the point for this test was to speed-up the span.start = span.stop no-op case.
| !! Variable.local_name ~var:"a" ~local_var:"x" | ||
| [cFunBody "ko_scope"; cLabel "l"]; | ||
|
|
||
| !! Variable.local_name ~var:"a" ~local_var:"x" [cFunBody "ok3"; tSpanSeq [cForBody "i"]]; |
There was a problem hiding this comment.
try doing more complex spans that don't start/end exactly on a sequence, and that contain allocations whose scope matters.
…xps. Meaning that any target with a regular expression (e.g. `sInstr`) was failing.
Fixed the span bug with Variable.local_name.
For that I :
p.s. : the modification of ShowAt is to solve another documented dependency issue, which has to link to this branch.