So I googl'ed a bit, but no information other than the sparse:
-Yrangepos Use range positions for syntax trees.
Ok. And I know I need to use it if I want to capture source fragments in a macro.
Now my two questions are:
All unsigned macros are disabled without notification. Enable all macros (not recommended, potentially dangerous code can run) Click this option to allow all macros to run. Using this setting makes your computer vulnerable to potentially malicious code and is not recommended.
In Excel, you cannot pause while recording a macro. Macro recorder doesn't create a perfect code, so make sure to clean up your code after recording.
Microsoft announced its plans to disable macros by default back in February to stop threat actors from abusing the feature to deliver malware via email attachments. “VBA macros are a common way for malicious actors to gain access to deploy malware and ransomware,” the company said.
Malicious macros can do almost anything that other malware can do to your system, including emulating ransomware, stealing data, and emailing itself out to your contacts.
The issue introducing -Yrangepos
back when makro was spelt Burmak(r)o is motivated by your use case.
A -X
option suggests permanence, while a -Y
could disappear at any time, which means it could become the default behavior.
Perhaps it hasn't because of bugs and crashes.
At a team meeting written up by Moors:
Range positions [martin]
Respecting range positions - decay in the ide which has to do with the fact that transformations in the typer or parser don’t respect range positions
- every checked in change - automatically check range positions
- range positions = not just a position point but start and end, contained in tree nodes (RangePosition is a subclass of Position)
- there is map of RangePositions in CompilationUnit
invariants:
- range positions of child nodes are contained in range pos of parent nodes
- no overlap (except for transparent range positions)
- rangepos cover whole program
problems:
- templates
- for
check files contain positions
rangeposition(start,point,end).focus == offsetposition(point) // escape from non-overlap invariant
In 2012, PR validation with -Yrangepos
failed frequently; it was fixed, but turned into a nightly validation to reduce resources.
Hubert offered these notes:
A few things about rangepos:
- if you try to run any code with 'scalac -Ybrowse:typer -Yrangepos FILE.scala' you will see that most of the trees have range positions.
- some don't, yes, that's a bit unfortunate but we are trying to improve on that - actually whenever you find such in Yrangepos mode it is possible that it is a bug. The situation has improved dramatically from 2.9 to 2.10.0-snapshots.
- syntactic trees are often assigned offset positions (this is something you might be experiencing but I would have to see an example)
- for the compiler we only care if range positions are valid up to (and including) typer. after that, we don't care. You are running your tool after refchecks from what I can see, this can interfere with a couple of transformations that happen in refchecks which can manipulate/assign range- or offset- positions.
It might seem easy to switch to range positions, because basic math, but there are still bugs like this one that demonstrate the extra labor involved in assigning positions when synthesizing or restructuring a tree.
Although range positions are needed for the presentation compiler, they aren't in the critical path for batch compilation. With more resources to improve robustness, maybe they could flip the switch.
I can only guess that scalac
by default does not use range positions for performance reasons.
In regular compilation, positions are used only for error reporting and saving line number information into classfiles. Offset positions are enough to do that, so there's no point in doing all the work required to manipulate range positions.
I don't think that range positions incur any other cost than simple compilation speed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With