zsh-highlighting return strange output on macosx - syntax-highlighting

I'm using zsh version 5.2 on macosx 10.11.6
When adding
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
as my last line of my .zshrc, everything work well in linux.
On macosx, when starting the terminal and for every command, I got the following output:
_zsh_highlight:13: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:14: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:18: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:21: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:24: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:25: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:27: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:28: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:29: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:32: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:32: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:35: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:36: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:39: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:39: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:43: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight_highlighter_main_predicate:3: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight_highlighter_main_predicate
_zsh_highlight_buffer_modified:2: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight_buffer_modified
_zsh_highlight:62: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
(eval):1: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:69: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:69: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:71: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:87: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:90: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:93: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:96: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:100: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
_zsh_highlight:101: scalar parameter ZSH_DEBUG_CMD created globally in function _zsh_highlight
The terminal also act strangely when typing. characters appear on everyline. The only similar bug that I found when googling was concerning phpbrew which is not installed on my system.

I just force an update on the repo and the bug is gone.
Problem was not in my environment.

Related

Why does thunk not demand as many parameters as function?

I'm dealing with the following thunk in Ghidra:
Now when I double-click the thunked function, Ghidra takes me to the real function, and I can see that it expects 2 parameters ("param_1" and "param_2").
Why is it allowed to call it with a single parameter ("&LAB_30007a18") only?
Thank you!
You showed the definition for the thunked function, but not the thunk. The thunk's signature may only include 1 param instead of 2. If so, fix that. Otherwise, the Decompiler may be confused by something earlier in the calling function (e.g., the 2nd param passed to the thunk is the return value from a previous call to a function that is currently defined as having a void return type).
The Decompiler can produce odd-looking results when functions are defined with incorrect parameters or return types.

How do I assign to member of type std::function<bool(wxString&)>

I have a custom Dialog class (derived from wxDialog). I want to add a setter so you can set a call back function MyDialog::m_f with some function of type std::function<bool(wxString&)>.
Later, the dialog will call this function.
I want to be able to pass in a lambda function (otherwise I could solve my problem with ordinary function pointers).
It must also be possible to call this setter multiple times, the last set value for m_f should be valid, thus erasing any previous set values (the value being a new function).
But, if I declare the member m_f, does it have to be initialized in the initializer list in the constructor?
For my use case that would not really work. I have to be able to set MyDialog::m_f after the dialog has been constructed (but before ShowModal is called).
Should my member m_f be a (unique) pointer to a std::function<bool(wxString&)>, so it can be set to nullptr in MyDialog::MyDialog?
My basic problem is I do not fully understand std::function. How can you make a variable of some std::function<...> type and assign a value (concrete function) to it later? What does it mean to have a variable like described which is uninitialized? How can I test whether it is (un)assigned? Is it at all possible to delay this assignment, that is: have a separate declaration and later initialization, or should a variable of std::function<...> be initialized immediately (like a const or reference)?
Thanks for any help.
BTW, the language is C++11 and we can't upgrade due to restrictions at work.
How can you make a variable of some std::function<...> type and assign a value (concrete function) to it later?
std::function has a default constructor that results in an "empty" instance. In your case, just declare the data member std::function<...> m_f and don't explicitly initialize it.
What does it mean to have a variable like described which is uninitialized?
That depends on the type of the variable. In the std::function, it's simply unusable. If you try to inoke an empty std::function, and exception will be thrown.
How can I test whether it is (un)assigned?
std::function has an explicit conversion operator to bool. It evaluates to true when the object is non-empty, i.e.
if (m_f)
m_f(/* parameters... */);
else
; // do nothing, not set yet
How can you make a variable of some std::function<...> type and assign a value (concrete function) to it later?
If you want to later assign lambda expression to the function object through a setter, you can turn this member function into a template, e.g.
template<class Fct>
void setCallback(Fct&& f)
{
m_f = std::forward<Fct>(f);
}
Another option is to pass a std::function with the desired signature to a non-template member function.

Get a reference to the script object

In V8 at least, in the debugger, you see local, script and global categorizing the variables.
I got a reference to global. All you do for that is set this on entry to a property to use later if need be.
However, I can't find how to save a reference to the script object. I think it exists because that's what the debugger is looping through in the watch window.
Before ES6, All declarations outside a function (and function declaration themselves) were properties of global object. After ES6, There are two kinds of global records:
Object record- Same as ES5.
Function declarations
Function generators
Variable assignments var
Declarative record - New
let, const, class, etc
Those in the declarative record are not accessible from the global "object", though they are globals themselves. They are accessible from the script, but the object/internal data structure holding the declarative records itself is not accessible or enumerable from inside the script. This declarative record is shown in v8 debugger as properties of script object.
References:
Global environment records
Related Answers:
ES6- What about introspection
Do let statements create properties on the global object

How to put lambda in a different section with GCC?

I'm using C++11 compiler to generate embedded code and I'd like to use lambda functions in it. However I need to put the actual generated code for my lambda functions in a different section or always inline it into the function/method where it is used (by default if some lambda function is not inlined it is put into '.text' section). Is there a way to set section attribute for the lambda function? Alternatively is there a way to make GCC compiler always inline lambda functions?
This will put the lambda in the .mylambdas section
auto myLambda = [&]() __attribute__((section(".mylambdas"))
{
...
};
Note : There's a bug with gcc where it complains if you use the same section name for lambdas in both regular class methods and const class methods. Clang is ok. One workaround is to use another section name for const methods, if that's possible.

Boost::asio async_wait handler signature

I am going through the boost::asio examples. I am looking at
Example 4
What is confusing is that, the WaitHandler in this example has the signature
void print (this)
But the async_wait call expects a handler whose
function signature of the handler must be:
void handler(
const boost::system::error_code& error // Result of operation.
);
Source: Boost documentation
Since the parameter type is part of a function's signature, why in the example above, async_wait accepts a handler whose parameter is not of type boost::system::error_code?
THanks.
As you correctly observe, the async_wait method accepts a handler function which takes one parameter (const boost::system::error_code&). But in the Timer.4 example, the call to async_wait is passed via boost bind as follows:
timer_.async_wait(boost::bind(&printer::print, this));
The boost::bind returns a function object which refers to method print for class printer for the object referenced by this. This function object is called by the async_wait method with the error parameter (since that is the signature it expects). But the error parameter is silently ignored because it is not referenced by the bind.
The official boost::bind documentation provides more details on boost::bind. See also the article How the Boost Bind Library Can Improve Your C++ Programs (there are probably many more articles available but I found this one very useful).
You specify in the call to async_wait what parameters your callback function takes, using placeholders. Check the sentence just above the async_wait call on the page you linked to:
You will note that the boost::asio::placeholders::error placeholder is
not specified here, as the print member function does not accept an
error object as a parameter.
Search for "placeholder" in this example and you'll see how to do it.

Resources