Skip to content

abs() not recognized as function if not after equals sign #902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
blopa1961 opened this issue Mar 10, 2022 · 5 comments
Closed

abs() not recognized as function if not after equals sign #902

blopa1961 opened this issue Mar 10, 2022 · 5 comments
Assignees
Labels
topic: language server Related to the Arduino Language Server type: imperfection Perceived defect in any part of project

Comments

@blopa1961
Copy link

blopa1961 commented Mar 10, 2022

Describe the bug

In arduino IDE abs() get marked as "no matching function for call to 'abs'" if it does not follow an equals sign.
(the program compiles without errors)

To Reproduce

Steps to reproduce the behavior:
in a new sketch select nodeMCU 1.0
write a statement like:

if (abs(i) < j) {
  etc...
}

abs (i) gets flagged as error in the IDE: "no matching function call for 'abs'"

k= abs(i); // this does not get flagged

same problem occurs if sprintf is not assigned to a variable, example:

sprintf(deciSecs, "%.1f",((float) timeStep) / 1000.0);

instead of

i= sprintf( etc... );

Expected behavior

I didn't expect this to be flagged

Desktop

  • Arduino IDE 2.0.0-rc5
  • OS: Windows 10 Pro
  • Version: 21H2
@blopa1961 blopa1961 added the type: imperfection Perceived defect in any part of project label Mar 10, 2022
@per1234
Copy link
Contributor

per1234 commented Mar 11, 2022

Hello @blopa1961. Thanks for your report.

We will need some additional information in order to effectively investigate this problem.

select nodeMCU 1.0

Please provide more detailed instructions. I can guess about what you mean, but I might have guessed wrong, and that wrong guess might be the reason I can't reproduce the bug you are experiencing.

I can see that this is a board from a 3rd party boards platform, but which specific boards platform?

Which version of that boards platform are you using?

Did you install it via Boards Manager, or did you install it to the sketchbook folder?

What is the exact name of the board as shown under the Tools > Board menu in the Arduino IDE (e.g., "NodeMCU 1.0 (ESP-12E Module)")?

write a statement like:

Please provide a complete minimal sketch we can use to reproduce the problem.

Provide one sketch for the abs issue, and another for the sprintf issue.

@per1234 per1234 added the topic: language server Related to the Arduino Language Server label Mar 11, 2022
@per1234 per1234 self-assigned this Mar 11, 2022
@blopa1961
Copy link
Author

Hello @per1234 and thank you for your fast reply.

About the 3rd party board, it's a standard nodeMCU.
To follow me:
open Arduino IDE, open preferences
in Additional Board Manager URLs add "http://arduino.esp8266.com/stable/package_esp8266com_index.json"
in Tools/Board esp8266 select nodeMCU 1.0 (ESP-12E module)

I tried to create a new sketch with the abs() or sprintf() problems but guess what, I can't reproduce the problem in a small sketch...

In the sketch I am working on now (which is more than 2000 lines long) it still happens, I attached a couple of screen captures where you can see the problems I reported.
When I opened my sketch the IDE did not initially flag abs(), but after I searched for "sprintf" both sprintf() and abs() were flagged (is this an uninitialized variable problem?) sorry, I'm a programmer too ;)

BTW my computer is a Core i7 with 32Gb RAM and a Samsung 850 Pro SSD disk, so I don't think this is a resource issue...

AbsFlagged
SprintfFlagged

Regards, blopa1961

@blopa1961
Copy link
Author

I keep investigating the issue, please take a look at this capture (!)
FlaggedComment
The abs() function got flagged, but it was underlined 4 lines below the actual abs() occurrence within a comment, but in the correct column. Please notice it is aligned below the abs() in line 557.
Also, please notice the } in line 559 (which ends the prevoius function) is also underlined and reports the same 'abs' problem. Is this a feature?

@ubidefeo ubidefeo added the status: waiting for information More information must be provided before work can proceed label Mar 24, 2022
@blopa1961
Copy link
Author

blopa1961 commented Apr 1, 2022

Hello @ubidefeo
I took the time to test a few of my small sketches and found one (attached) where printf (and also setenv, time, asctime, localtime, etc.) get flagged as you can see in the screen capture:
FlaggedFunctions
NTP_Time.zip

I hope you can reproduce the problem this time.
Regards, blopa1961

@Looky1173
Copy link

It seems like most built-in functions are getting flagged like so:
image

@per1234 per1234 removed the status: waiting for information More information must be provided before work can proceed label Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: language server Related to the Arduino Language Server type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

4 participants