vgvassilev / cling

The interactive C++ interpreter Cling
https://rawgit.com/vgvassilev/cling/master/www/index.html
Other
1.76k stars 102 forks source link

process with `disableValuePrinting` set to true #184

Open gouarin opened 6 years ago

gouarin commented 6 years ago

In https://github.com/QuantStack/xeus-cling, we changed a little bit the way to process the input given in a cell notebook in order to write the output cleanly. To do that, we use the flag disableValuePrinting in the process method of the MetaProcessor and we found a bug.

Here is a simple example which illustrates the issue in the cling interpreter

#include <iostream>
#include "cling/Interpreter/Value.h"
#include "cling/Utils/Output.h"
#include "cling/MetaProcessor/MetaProcessor.h"

cling::MetaProcessor processor(*gCling, cling::errs());
cling::Value output;
cling::Interpreter::CompilationResult compilation_result;

std::string myinput{R"(auto test = [](auto i){std::cout << i << "\n";};)"};

processor.process(myinput, compilation_result, &output, true);
test(5)

The error message is

input_line_13:2:2: error: type '(lambda at input_line_12:2:14)' does not provide a call operator
 test(5)

Note that if you add a semicolon at the end of the myinput string, the problem is solved.

std::string myinput{R"(auto test = [](auto i){std::cout << i << "\n";};;)"};

It's a critical issue for xeus-cling and we hope that you can fix it soon in order to add a patch in your build process.

SylvainCorlay commented 6 years ago

Subscribing!

vgvassilev commented 6 years ago

I will take a look.