comparison libinterp/parse-tree/pt-idx.cc @ 31073:396f60e0b984

maint: merge stable to default
author Arun Giridhar <arungiridhar@gmail.com>
date Sun, 05 Jun 2022 18:11:28 -0400
parents 08b08b7f05b2 277e31f0bb60
children e88a07dec498
comparison
equal deleted inserted replaced
31070:398a67a91798 31073:396f60e0b984
364 bool is_var = tw.is_variable (m_expr); 364 bool is_var = tw.is_variable (m_expr);
365 365
366 std::string nm = id->name (); 366 std::string nm = id->name ();
367 367
368 if (is_var && is_word_list_cmd ()) 368 if (is_var && is_word_list_cmd ())
369 error ("%s used as variable and later as function", nm.c_str ()); 369 {
370 bool maybe_binary_op = false;
371 if ((*p_args) && (*p_args)->length () > 0)
372 {
373 // check if first character of first argument might be (the
374 // start of) a binary operator
375 std::string ops = "+-*/\\.^|&";
376 string_vector arg_list = (*p_args)->get_arg_names ();
377 if (! arg_list.isempty ()
378 && (ops.find (arg_list(0)[1]) != std::string::npos))
379 maybe_binary_op = true;
380 }
381
382 std::string advice;
383 if (maybe_binary_op)
384 advice = "\nCheck whitespace around potential binary operator.";
385
386 error ("variable \"%s\" used as function in command style expression%s",
387 nm.c_str (), advice.c_str ());
388 }
370 389
371 if (! is_var) 390 if (! is_var)
372 { 391 {
373 octave_value_list first_args; 392 octave_value_list first_args;
374 393