"%s is not allowed inside DO IF or LOOP."),
command->name);
+ case S_NESTED_INPUT_PROGRAM:
+ return xasprintf (_("%s is not allowed inside DO IF or LOOP "
+ "(except inside INPUT PROGRAM)."),
+ command->name);
+
default:
NOT_REACHED ();
}
/* Commands that define (or replace) the active dataset. */
DEF_CMD (S_INITIAL | S_DATA, 0, "ADD FILES", cmd_add_files)
-DEF_CMD (S_ANY, 0, "DATA LIST", cmd_data_list)
+DEF_CMD (S_INITIAL | S_DATA | S_INPUT_PROGRAM | S_FILE_TYPE | S_NESTED_INPUT_PROGRAM,
+ 0, "DATA LIST", cmd_data_list)
DEF_CMD (S_INITIAL | S_DATA, 0, "GET", cmd_get)
DEF_CMD (S_INITIAL | S_DATA, 0, "GET DATA", cmd_get_data)
DEF_CMD (S_INITIAL | S_DATA, 0, "IMPORT", cmd_import)
╰────────┴──────┴───────┴──────╯
])
AT_CLEANUP
+
+# Checks for a bug where DATA LIST was allowed inside LOOP, which
+# cleared the dataset and caused LOOP to assert-fail because its
+# transformation stack entry had been popped.
+AT_SETUP([DATA LIST inside LOOP])
+AT_DATA([data-list.sps], [dnl
+DATA LIST LIST NOTABLE/x y z.
+LOOP.
+DATA LIST.
+END LOOP.
+])
+AT_CHECK([pspp data-list.sps], [1], [dnl
+data-list.sps:3.1-3.9: error: DATA LIST: DATA LIST is not allowed inside DO IF
+or LOOP (except inside INPUT PROGRAM).
+ 3 | DATA LIST.
+ | ^~~~~~~~~
+])
+AT_CLEANUP
\ No newline at end of file