Skip to content

Commit

Permalink
Move input check for SyntaxTree to SYNTAX_TREE
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Pfeiffer committed Jul 11, 2018
1 parent a7c1e0b commit 6ba8176
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 0 additions & 5 deletions lib/syntaxtree.gi
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
#
InstallGlobalFunction( SyntaxTree,
function(f)
# TODO: Maybe move this to the kernel function
if IsOperation(f) or IsKernelFunction(f) then
Error("f has to be a GAP function (not an operation or a kernel function)");
fi;

return Objectify( SyntaxTreeType, rec( file := FilenameFunc(f)
, line := StartlineFunc(f)
, tree := SYNTAX_TREE(f) ) );
Expand Down
10 changes: 5 additions & 5 deletions src/syntaxtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ typedef struct {
static const CompilerT Compilers[];
#define COMPILER_ARITY(...) (sizeof((ArgT[]){ __VA_ARGS__ }) / sizeof(ArgT))
#define COMPILER(tnum, compiler, ...) \
[tnum] = \
{ tnum, compiler, #tnum, COMPILER_ARITY(__VA_ARGS__), { __VA_ARGS__ } }

[tnum] = { \
tnum, compiler, #tnum, COMPILER_ARITY(__VA_ARGS__), { __VA_ARGS__ } \
}

#define COMPILER_(tnum, ...) \
COMPILER(tnum, SyntaxTreeDefaultCompiler, __VA_ARGS__)
Expand Down Expand Up @@ -863,8 +863,8 @@ Obj FuncSYNTAX_TREE(Obj self, Obj func)
{
Obj result;

if (!IS_FUNC(func)) {
ErrorQuit("SYNTAX_TREE: <func> must be a function (not a %s)",
if (!IS_FUNC(func) || IsKernelFunction(func) || IS_OPERATION(func)) {
ErrorQuit("SYNTAX_TREE: <func> must be a plain GAP function",
(Int)TNAM_OBJ(func), 0L);
}

Expand Down
6 changes: 5 additions & 1 deletion tst/testinstall/syntaxtree.tst
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

#
gap> SYNTAX_TREE(1);
Error, SYNTAX_TREE: <func> must be a function (not a integer)
Error, SYNTAX_TREE: <func> must be a plain GAP function
gap> SYNTAX_TREE(\+);
Error, SYNTAX_TREE: <func> must be a plain GAP function



# Just try compiling all functions we can find in the workspace
# to see nothing crashes.
Expand Down

0 comments on commit 6ba8176

Please sign in to comment.