Skip to content
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

Number subindexes not detected #164

Closed
Lartu opened this issue Dec 5, 2019 · 5 comments
Closed

Number subindexes not detected #164

Lartu opened this issue Dec 5, 2019 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@Lartu
Copy link
Owner

Lartu commented Dec 5, 2019

At the moment, the LDPL compiler doesn't find any errors in codes like

data:
myNum is number
otherNum is number

procedure:
store myNum:0 in otherNum

and thus the C++ compilation crashes after the IR is generated. This should be fixed 😞

@Lartu Lartu added the bug Something isn't working label Dec 5, 2019
@Lartu Lartu added this to the LDPL 4.4-rev milestone Dec 5, 2019
@Lartu Lartu pinned this issue Dec 5, 2019
@Lartu
Copy link
Owner Author

Lartu commented Dec 5, 2019

@dgarroDC as you were working with sub-indexes and all that in the recent days (and thus you should remember how this all works better), is there any chance you could look into this issue?

@dgarroDC
Copy link
Collaborator

dgarroDC commented Dec 5, 2019

I can't debug this right now but after a quick look at the code, I think that this might be the problem, maybe we should also check that indexes if empty.

But anyway, can the is_num_var be simplified by just calling variable_type with the full token and verifying if the type is NUMBER? I mean, something like this:

bool is_num_var(string & token, compiler_state & state)
{
    return (variable_type(token, state) == vector<unsigned int>{1});
}

This is related to the bug we discussed here (is_num_var was returning true incorrectly), but when I fixed it (by replacing token with var_name), I removed that false positive but introduced this new false positive. In conclusion, it was okay to use token, the problem was all the other logic (dealing with indexes). We can remove all that logic and use token again, and the resulting function is much simpler.

This all also applies to the text case, of course.

@Lartu
Copy link
Owner Author

Lartu commented Dec 6, 2019

You are right, I do like the simpler function. We should take that approach.

@dgarroDC
Copy link
Collaborator

dgarroDC commented Dec 6, 2019

Fixed!

@dgarroDC dgarroDC unpinned this issue Dec 6, 2019
@Lartu
Copy link
Owner Author

Lartu commented Dec 7, 2019

Wonderful! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants