Skip to content

Commit

Permalink
panc: Deprecated should always return boolean true
Browse files Browse the repository at this point in the history
This allows us to start removing the hundreds of instances of `... with {deprecated(...); true;}` in the schema.

It's not clear why it ever returned undef, but it appears to have been this way since the original rewrite in Java and looks like it was originally default boilerplate for new functions.
The documentation and comments claim it should be returning the string passed to it, but this has never been the case.
  • Loading branch information
jrha committed Jan 24, 2025
1 parent 8b68c11 commit daddb31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
10 changes: 4 additions & 6 deletions panc-docs/source/standard-functions/standard-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,14 @@ deprecated -- print deprecation warning to console
Synopsis
--------

string **deprecated** (long *level*, string *msg*)
boolean **deprecated** (long *level*, string *msg*)

Description
-----------

This function will print the given string to the console (on stderr) and
return the message as the result, if ``level`` is less than or equal to
the deprecation level given as a compiler option. If the message is not
printed, the function returns undef. The value of ``level`` must be
non-negative.
This function will print the given string to the console (on stderr), if
``level`` is less than or equal to the deprecation level given as a compiler
option and always returns true. The value of ``level`` must be non-negative.

.. _dict:

Expand Down
11 changes: 5 additions & 6 deletions panc/src/main/java/org/quattor/pan/dml/functions/Deprecated.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,18 @@ Centre National de la Recherche Scientifique (CNRS).
import org.quattor.pan.dml.data.Element;
import org.quattor.pan.dml.data.LongProperty;
import org.quattor.pan.dml.data.StringProperty;
import org.quattor.pan.dml.data.Undef;
import org.quattor.pan.dml.data.BooleanProperty;
import org.quattor.pan.exceptions.EvaluationException;
import org.quattor.pan.exceptions.SyntaxException;
import org.quattor.pan.ttemplate.Context;
import org.quattor.pan.ttemplate.SourceRange;

/**
* Prints the argument to the standard error stream if the given level is less
* than or equal to the deprecation level option. The returned value is the
* message, if the message is printed; undef, otherwise.
*
* than or equal to the deprecation level option. The returned value is always true.
*
* @author loomis
*
*
*/
// FIXME: This method should really only accept one argument now.
final public class Deprecated extends BuiltInFunction {
Expand Down Expand Up @@ -91,7 +90,7 @@ public Element execute(Context context) {

assert (ops.length == 2);

Element value = Undef.VALUE;
Element value = BooleanProperty.TRUE;

if (!context.isCompileTimeContext()) {

Expand Down

0 comments on commit daddb31

Please sign in to comment.