When infix operators are defined to have labeled arguments, such as:
let (++) ~n1 ~n2 = n1 + n2
... applications of the infix operator using labeled arguments like
this:
(++) ~n1:10 ~n2:20
would be printed out like this, which is a syntax error:
~n1:10 ++ ~n2:20
This module checks all the AST invariants. This is to ensure that all
invariants are written down in one place and are consistently checked
between the various clients of the AST (typer, pprintast, ...).
The invariants are checked in Pparsee, after applying the ppx
rewriters.
The current fix is to rely on the parsing rules for generic module types, and then
extract a package type, enabling more explicit error messages. Alternatively, one
could keep the generic module type in the Parsetree and extract the package type
at type-checking time. But I don't feel like touching the Parsetree definition so
close from a release, consider the impact on Camlp4/5, PPX mappers and other
syntactic tools.
This commit adds a hook in "parsing/lexer.ml{i,l}" to deactivate the generation of
docstring items. This hook is used by ocamldoc to avoid interferences between these
items and the ocamldoc documentation comments parser.
When a ppx raised an exception, it was returned as an error "extension node" to
the caller, without including the "ppx context" which includes in particular ppx
cookies. This was fine when only one ppx was used, since in that case, the
missing context was not restored.
When multiple ppx are chained, however, the second ppx sees the result of the
first one, and it it does not contains a context, an empty one is created and
returned to the caller, which has the effect of destroying the context for the
next invocation of ppxs.
The current fix is to ensure that when a "error extension node" is returned, the
context is correctly added to it. In addition to fixing the reported bug, it also
allow ppx to update their cookies before raising an exception, which can be
useful.
.. and allow any letter in [g-zG-Z] as modifier (previously 'l','L','n')
Also allow modifier for floats
This give more freedom to ppx rewritters (what about a ppx for zarith)
Checks are performed when translating from Parsetree to Typedtree.
Invalid_literal is raised if the modifier is not recognized ([lLn]?)
Integer_overflow is raised as before.
Lexer: use g-zG-Z for integer literal modifier
Lexer: Allow modifier on float
Clean wrt previous commits
Lexer: use named substring
Cleanup
typo
doc
fix after rebase
rebase on trunk
Update typecore.ml
Fix printast.ml
This form used to produce Pstr_eval instead of Pstr_let. This would
probably come as a suprise for people matching on the Parsetree (e.g.
for a ppx). This special case is now removed.
To avoid a (probably harmless) regression in bytecode, the compilation
of "let _ = ..." bindings (including local ones) is optimized to remove
a useless introduction of a variable (which would occupy a stack slot
otherwise).
The source code printer (-dsource) now prints Pstr_eval as ";;expr",
which should always be ok. One could avoid ";;" at the beginning of
the structure, but since it is allowed, it is probably not worth adding
complexity here.