[TRDR-42] Allow wrapping constants so their location can be accessed Created: 18/Mar/17 Updated: 19/Mar/17 Resolved: 19/Mar/17
|Reporter:||Thomas Heller||Assignee:||Nicola Mometto|
Currently the reader will lose all source information (line, column, end-line, end-column, file) on values that don't support metadata.
This change allows (optionally) wrapping everything that doesn't support metadata in the Constant record.
This would allow the CLJS analyzer to show correct locations that it currently cannot do in some circumstances.
The location of "2" is unknown and thus the location of the error is that of the +.
The default behaviour is unchanged.
With wrapping enabled you'd get:
The loc-info property of the Constant record could be moved to the metadata of the record.
The CLJS analyzer could easily unwrap this and extract the correct location info to merge that into the AST.
|Comment by Thomas Heller [ 18/Mar/17 5:07 AM ]|
The implementation is currently available here .
I first wanted to confirm that this is something worth considering before cutting actual patches. This change can easily be ported to the CLJS/EDN readers as well.
|Comment by Thomas Heller [ 18/Mar/17 11:55 AM ]|
My initial enthusiasm was crushed by macroexpand. As soon as any macro does any kind of type detection on values it receives this whole approach breaks down. Unwrapping the form before handing it to macroexpand has the same effect as not having the information in the first place as analyze happens after expansion.
So while I still think this would be useful for tools, it is not viable for the analyzer.
|Comment by Thomas Heller [ 19/Mar/17 2:35 AM ]|
Even from a tools perspective this isn't all that useful as it makes for sense to wrap everything and not eval tagged literals.
Sorry for the noise.