summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Shinwell <mshinwell@janestreet.com>2015-11-30 14:55:50 +0000
committerMark Shinwell <mshinwell@janestreet.com>2015-11-30 14:55:50 +0000
commitdf2ee010f031fc77899bc79268bfa3e91f2b378b (patch)
treeb46377664d898adf7f0272736eaba6bda64aeb12
parente9dd8ba557daab582495221e6053fc51f7d1402f (diff)
parent9a09b322a52552bf2dfeafffa07e55cd0a1d6208 (diff)
downloadocaml-df2ee010f031fc77899bc79268bfa3e91f2b378b.tar.gz
Merge remote-tracking branch 'ocaml/trunk' into flambda_trunk
-rw-r--r--bytecomp/translcore.ml3
-rw-r--r--manual/manual/refman/expr.etex64
-rw-r--r--manual/manual/refman/exten.etex110
-rw-r--r--manual/manual/refman/patterns.etex16
-rw-r--r--testsuite/tests/backtrace/Makefile8
-rw-r--r--testsuite/tests/backtrace/pr6920_why_at.ml9
-rw-r--r--testsuite/tests/backtrace/pr6920_why_at.reference4
-rw-r--r--testsuite/tests/backtrace/pr6920_why_swallow.ml11
-rw-r--r--testsuite/tests/backtrace/pr6920_why_swallow.reference4
9 files changed, 112 insertions, 117 deletions
diff --git a/bytecomp/translcore.ml b/bytecomp/translcore.ml
index fd633e1191..733740e3a2 100644
--- a/bytecomp/translcore.ml
+++ b/bytecomp/translcore.ml
@@ -642,7 +642,8 @@ let primitive_is_ccall = function
(* Determine if a primitive is a Pccall or will be turned later into
a C function call that may raise an exception *)
| Pccall _ | Pstringrefs | Pstringsets | Parrayrefs _ | Parraysets _ |
- Pbigarrayref _ | Pbigarrayset _ | Pduprecord _ -> true
+ Pbigarrayref _ | Pbigarrayset _ | Pduprecord _ | Pdirapply _ |
+ Prevapply _ -> true
| _ -> false
(* Assertions *)
diff --git a/manual/manual/refman/expr.etex b/manual/manual/refman/expr.etex
index 4e9548ff84..5d793b7cde 100644
--- a/manual/manual/refman/expr.etex
+++ b/manual/manual/refman/expr.etex
@@ -69,6 +69,11 @@ expr:
| '(' expr ':>' typexpr ')'
| '(' expr ':' typexpr ':>' typexpr ')'
| '{<' [ inst-var-name '=' expr { ';' inst-var-name '=' expr } [';'] ] '>}'
+ | 'assert' expr
+ | 'lazy' expr
+ | 'let' 'module' module-name { '(' module-name ':' module-type ')' }
+ [ ':' module-type ] \\ '=' module-expr 'in' expr
+
;
%BEGIN LATEX
\end{syntax} \begin{syntax}
@@ -116,8 +121,8 @@ precedence come first. For infix and prefix symbols, we write
\entree{". .( .[ .{" (see section~\ref{s:bigarray-access})}{--}
\entree{"#"\ldots}{--}
\entree{function application, constructor application, tag
- application, "assert" (see~\ref{s:assert}),
- "lazy" (see~\ref{s:lazy})}{left}
+ application, "assert",
+ "lazy"}{left}
\entree{"- -." (prefix)}{--}
\entree{"**"\ldots" lsl lsr asr"}{right}
\entree{"*"\ldots" /"\ldots" %"\ldots" mod land lor lxor"}{left}
@@ -834,4 +839,59 @@ For abstract and private types, the variance must be given explicitly
otherwise the default is nonvariant. This is also the case for
constrained arguments in type definitions.
+
+\subsection{Other}
+
+\subsubsection*{Assertion checking}
+
+
+\ikwd{assert\@\texttt{assert}}
+
+OCaml supports the @"assert"@ construct to check debugging assertions.
+The expression @"assert" expr@ evaluates the expression @expr@ and
+returns @"()"@ if @expr@ evaluates to @"true"@. If it evaluates to
+@"false"@ the exception
+"Assert_failure" is raised with the source file name and the
+location of @expr@ as arguments. Assertion
+checking can be turned off with the "-noassert" compiler option. In
+this case, @expr@ is not evaluated at all.
+
+As a special case, @"assert false"@ is reduced to
+@'raise' '('@"Assert_failure ..."@')'@, which gives it a polymorphic
+type. This means that it can be used in place of any expression (for
+example as a branch of any pattern-matching). It also means that
+the @"assert false"@ ``assertions'' cannot be turned off by the
+"-noassert" option.
+%
+\index{Assertfailure\@\verb`Assert_failure`}
+
+\subsubsection*{Lazy expressions}
+\ikwd{lazy\@\texttt{lazy}}
+
+The expression @"lazy" expr@ returns a value \var{v} of type "Lazy.t" that
+encapsulates the computation of @expr@. The argument @expr@ is not
+evaluated at this point in the program. Instead, its evaluation will
+be performed the first time the function "Lazy.force" is applied to the value
+\var{v}, returning the actual value of @expr@. Subsequent applications
+of "Lazy.force" to \var{v} do not evaluate @expr@ again. Applications
+of "Lazy.force" may be implicit through pattern matching (see~\ref{s:lazypat}).
+
+\subsubsection*{Local modules}
+\ikwd{let\@\texttt{let}}
+\ikwd{module\@\texttt{module}}
+
+The expression
+@"let" "module" module-name "=" module-expr "in" expr@
+locally binds the module expression @module-expr@ to the identifier
+@module-name@ during the evaluation of the expression @expr@.
+It then returns the value of @expr@. For example:
+\begin{verbatim}
+ let remove_duplicates comparison_fun string_list =
+ let module StringSet =
+ Set.Make(struct type t = string
+ let compare = comparison_fun end) in
+ StringSet.elements
+ (List.fold_right StringSet.add string_list StringSet.empty)
+\end{verbatim}
+
%% \newpage
diff --git a/manual/manual/refman/exten.etex b/manual/manual/refman/exten.etex
index 83d6a23a00..c13dc8d411 100644
--- a/manual/manual/refman/exten.etex
+++ b/manual/manual/refman/exten.etex
@@ -34,21 +34,6 @@ The library modules "Int32"[\moduleref{Int32}],
"Int64"[\moduleref{Int64}] and "Nativeint"[\moduleref{Nativeint}]
provide operations on these integer types.
-\section{Streams and stream parsers} \label{s:streams}
-
-(Removed in Objective Caml 3.03)
-
-The syntax for streams and stream parsers is no longer part of the
-OCaml language, but available through a Camlp4 syntax
-extension. See the Camlp4 reference manual for more information.
-Support for basic operations on streams is still available through the
-"Stream"[\moduleref{Stream}] module of the standard library.
-OCaml programs
-that use the stream parser syntax should be compiled with the
-"-pp camlp4o" option to "ocamlc" and "ocamlopt". For interactive use,
-run "ocaml" and issue the \verb'#load "dynlink.cma";;' command,
-followed by the \verb'#load "camlp4o.cma";;' command.
-
\section{Recursive definitions of values} \label{s:letrecvalues}
(Introduced in Objective Caml 1.00)
@@ -118,74 +103,8 @@ An expression @@e@@ is said to be {\em immediately linked to} the variable
is immediately linked to @name@.
\end{itemize}
-\section{Range patterns} \label{s:range-patterns}
-
-(Introduced in Objective Caml 1.00)
-
-\begin{syntax}
-pattern: ...
- | char-literal '..' char-literal
-\end{syntax}
-
-In patterns, OCaml recognizes the form
-@"'" @c@ "'" ".." "'" @d@ "'"@ as shorthand for the pattern
-\begin{center}
-@"'" @c@ "'" "|" "'" @c@_1 "'" "|" "'" @c@_2 "'" "|" \ldots
- "|" "'" @c@_n "'" "|" "'" @d@ "'"@
-\end{center}
-where \nth{c}{1}, \nth{c}{2}, \ldots, \nth{c}{n} are the characters
-that occur between \var{c} and \var{d} in the ASCII character set. For
-instance, the pattern "'0'"@'..'@"'9'" matches all characters that are digits.
-
-\section{Assertion checking}\label{s:assert}
-\ikwd{assert\@\texttt{assert}}
-
-(Introduced in Objective Caml 1.06)
-
-\begin{syntax}
-expr: ...
- | 'assert' expr
-\end{syntax}
-
-OCaml supports the @"assert"@ construct to check debugging assertions.
-The expression @"assert" expr@ evaluates the expression @expr@ and
-returns @"()"@ if @expr@ evaluates to @"true"@. If it evaluates to
-@"false"@ the exception
-"Assert_failure" is raised with the source file name and the
-location of @expr@ as arguments. Assertion
-checking can be turned off with the "-noassert" compiler option. In
-this case, @expr@ is not evaluated at all.
-
-As a special case, @"assert false"@ is reduced to
-@'raise' '('@"Assert_failure ..."@')'@, which gives it a polymorphic
-type. This means that it can be used in place of any expression (for
-example as a branch of any pattern-matching). It also means that
-the @"assert false"@ ``assertions'' cannot be turned off by the
-"-noassert" option.
-%
-\index{Assertfailure\@\verb`Assert_failure`}
-
-
-\section{Lazy evaluation} \label{s:lazy}
-\ikwd{lazy\@\texttt{lazy}}
-
-\subsection{Lazy expressions}
-(Introduced in Objective Caml 1.06)
-
-\begin{syntax}
-expr: ...
- | 'lazy' expr
-\end{syntax}
-
-The expression @"lazy" expr@ returns a value \var{v} of type "Lazy.t" that
-encapsulates the computation of @expr@. The argument @expr@ is not
-evaluated at this point in the program. Instead, its evaluation will
-be performed the first time the function "Lazy.force" is applied to the value
-\var{v}, returning the actual value of @expr@. Subsequent applications
-of "Lazy.force" to \var{v} do not evaluate @expr@ again. Applications
-of "Lazy.force" may be implicit through pattern matching (see below).
+\section{Lazy patterns} \label{s:lazypat}
-\subsection{Lazy patterns}
(Introduced in Objective Caml 3.11)
\begin{syntax}
@@ -210,33 +129,6 @@ standard library (
\index{Lazy (module)\@\verb`Lazy` (module)}%
\index{force\@\verb`force`}%
-\section{Local modules}
-\ikwd{let\@\texttt{let}}
-\ikwd{module\@\texttt{module}}
-
-(Introduced in Objective Caml 2.00)
-
-\begin{syntax}
-expr:
- ...
- | 'let' 'module' module-name { '(' module-name ':' module-type ')' }
- [ ':' module-type ] \\ '=' module-expr 'in' expr
-\end{syntax}
-
-The expression
-@"let" "module" module-name "=" module-expr "in" expr@
-locally binds the module expression @module-expr@ to the identifier
-@module-name@ during the evaluation of the expression @expr@.
-It then returns the value of @expr@. For example:
-\begin{verbatim}
- let remove_duplicates comparison_fun string_list =
- let module StringSet =
- Set.Make(struct type t = string
- let compare = comparison_fun end) in
- StringSet.elements
- (List.fold_right StringSet.add string_list StringSet.empty)
-\end{verbatim}
-
\section{Recursive modules} \label{s-recursive-modules}
\ikwd{module\@\texttt{module}}
\ikwd{rec\@\texttt{rec}}
diff --git a/manual/manual/refman/patterns.etex b/manual/manual/refman/patterns.etex
index fa286e0886..518ce8cea3 100644
--- a/manual/manual/refman/patterns.etex
+++ b/manual/manual/refman/patterns.etex
@@ -19,6 +19,7 @@ pattern:
| '[' pattern { ';' pattern } [ ';' ] ']'
| pattern '::' pattern
| '[|' pattern { ';' pattern } [ ';' ] '|]'
+ | char-literal '..' char-literal
\end{syntax}
The table below shows the relative precedences and associativity of
@@ -26,8 +27,8 @@ operators and non-closed pattern constructions. The constructions with
higher precedences come first.
\ikwd{as\@\texttt{as}}
\begin{tableau}{|l|l|}{Operator}{Associativity}
-\entree{".." (see section~\ref{s:range-patterns})}{--}
-\entree{"lazy" (see section~\ref{s:lazy})}{--}
+\entree{".."}{--}
+\entree{"lazy" (see section~\ref{s:lazypat})}{--}
\entree{Constructor application, Tag application}{right}
\entree{"::"}{right}
\entree{","}{--}
@@ -147,3 +148,14 @@ The pattern @"[|" pattern_1 ";" \ldots ";" pattern_n "|]"@
matches arrays of length $n$ such that the $i$-th array element
matches the pattern @pattern_i@, for \fromoneto{i}{n}.
+\subsubsection*{Range patterns}
+
+The pattern
+@"'" @c@ "'" ".." "'" @d@ "'"@ is a shorthand for the pattern
+\begin{center}
+@"'" @c@ "'" "|" "'" @c@_1 "'" "|" "'" @c@_2 "'" "|" \ldots
+ "|" "'" @c@_n "'" "|" "'" @d@ "'"@
+\end{center}
+where \nth{c}{1}, \nth{c}{2}, \ldots, \nth{c}{n} are the characters
+that occur between \var{c} and \var{d} in the ASCII character set. For
+instance, the pattern "'0'"@'..'@"'9'" matches all characters that are digits.
diff --git a/testsuite/tests/backtrace/Makefile b/testsuite/tests/backtrace/Makefile
index 1d638f5427..6faa1a26a3 100644
--- a/testsuite/tests/backtrace/Makefile
+++ b/testsuite/tests/backtrace/Makefile
@@ -16,7 +16,8 @@ EXECNAME=program$(EXE)
ABCDFILES=backtrace.ml
OTHERFILES=backtrace2.ml raw_backtrace.ml \
backtrace_deprecated.ml backtrace_slots.ml
-OTHERFILESNOINLINING=backtraces_and_finalizers.ml
+OTHERFILESNOINLINING=pr6920_why_at.ml pr6920_why_swallow.ml
+OTHERFILESNOINLINING_NATIVE=backtraces_and_finalizers.ml
default:
@$(MAKE) byte
@@ -37,7 +38,7 @@ byte:
&& echo " => passed" || echo " => failed"; \
done; \
done
- @for file in $(OTHERFILES); do \
+ @for file in $(OTHERFILES) $(OTHERFILESNOINLINING); do \
rm -f program program.exe; \
$(OCAMLC) -g -o $(EXECNAME) $$file; \
printf " ... testing '$$file' with ocamlc:"; \
@@ -75,7 +76,8 @@ native:
$(DIFF) $$F.reference $$F.native.result >/dev/null \
&& echo " => passed" || echo " => failed"; \
done;
- @for file in $(OTHERFILESNOINLINING); do \
+ @for file in $(OTHERFILESNOINLINING) $(OTHERFILESNOINLINING_NATIVE); \
+ do \
rm -f program program.exe; \
$(OCAMLOPT) -inline 0 -g -o $(EXECNAME) $$file; \
printf " ... testing '$$file' with ocamlopt:"; \
diff --git a/testsuite/tests/backtrace/pr6920_why_at.ml b/testsuite/tests/backtrace/pr6920_why_at.ml
new file mode 100644
index 0000000000..2bacd9fd4c
--- /dev/null
+++ b/testsuite/tests/backtrace/pr6920_why_at.ml
@@ -0,0 +1,9 @@
+let why : unit -> unit = fun () -> raise Exit
+let f () =
+ why @@ ();
+ ignore (3 + 2);
+ ()
+
+let () =
+ Printexc.record_backtrace true;
+ f ()
diff --git a/testsuite/tests/backtrace/pr6920_why_at.reference b/testsuite/tests/backtrace/pr6920_why_at.reference
new file mode 100644
index 0000000000..dcc2fcc1e8
--- /dev/null
+++ b/testsuite/tests/backtrace/pr6920_why_at.reference
@@ -0,0 +1,4 @@
+Fatal error: exception Pervasives.Exit
+Raised at file "pr6920_why_at.ml", line 1, characters 41-45
+Called from file "pr6920_why_at.ml", line 3, characters 2-11
+Called from file "pr6920_why_at.ml", line 9, characters 2-6
diff --git a/testsuite/tests/backtrace/pr6920_why_swallow.ml b/testsuite/tests/backtrace/pr6920_why_swallow.ml
new file mode 100644
index 0000000000..5938956d0f
--- /dev/null
+++ b/testsuite/tests/backtrace/pr6920_why_swallow.ml
@@ -0,0 +1,11 @@
+let why : unit -> unit = fun () -> raise Exit
+let f () =
+ for i = 1 to 10 do
+ why @@ ();
+ done;
+ ignore (3 + 2);
+ ()
+
+let () =
+ Printexc.record_backtrace true;
+ f ()
diff --git a/testsuite/tests/backtrace/pr6920_why_swallow.reference b/testsuite/tests/backtrace/pr6920_why_swallow.reference
new file mode 100644
index 0000000000..ad66532f31
--- /dev/null
+++ b/testsuite/tests/backtrace/pr6920_why_swallow.reference
@@ -0,0 +1,4 @@
+Fatal error: exception Pervasives.Exit
+Raised at file "pr6920_why_swallow.ml", line 1, characters 41-45
+Called from file "pr6920_why_swallow.ml", line 4, characters 4-14
+Called from file "pr6920_why_swallow.ml", line 11, characters 2-6