Closed finanalyst closed 2 months ago
@coke bringing this to your attention. The new highlighter @lizmat is developing will require error free examples.
The problem here is simple to fix and is unlikely to be the only one in the documentation suite
Each code section (between =begin code
and =end code
or in an indented section without blanks lines) will need to compile correctly in order to highlight
@coke Note that in this case, I just realized, that the problem is really that in RakuAST the following is a sorry, rather than a worry:
my $a = 666;
my $a = 42;
say $a
In this particular example, I think it should have the my
removed. But there will be other cases, where the fact that RakuAST isn't ready yet, will affect highlighting.
@finanalyst If the highlighting results in an execution error, I suggest we skip highlighting for that particular piece of code, altogether for now. And that we collect these cases, as issues rakudo/rakudo marked RakuAST specific?
Notes:
Only partial code is provided in many cases. If the example is meant to compile, a preamble is preprended to the code that is NOT intended to be visible to the author. Until now this preamble has only been used for xt/examples-compilation.rakutest
There are several examples where code is shown as a deliberate bad example where it is not intended to be correct. (This isn't one of those)
Unless there's a tag on the code block, we compile it during 'make xtest' and this snippet should fail as is if it doesn't compile. (non-raku and deliberately broken code are skipped by passing an :attribute to the code block)
As @lizmat notes, this code compiles successfully and passes xt/examples_compilation.rakutest before your change. (It emits "potential difficulties" but runs successfully).
So, I'll apply this because it shows a bad example, but not one that doesn't compile.
@finanalyst If the highlighting results in an execution error, I suggest we skip highlighting for that particular piece of code, altogether for now. And that we collect these cases, as issues rakudo/rakudo marked RakuAST specific?
Could we add this to the error-report page?
The problem
Example in code will cause an error in RakuAST, redeclaration of 'my $a'
Solution provided
remove second 'my'