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

About function redefinition & the evaluation bar #64

Open
Kerl13 opened this issue Oct 9, 2018 · 0 comments
Open

About function redefinition & the evaluation bar #64

Kerl13 opened this issue Oct 9, 2018 · 0 comments

Comments

@Kerl13
Copy link
Contributor

Kerl13 commented Oct 9, 2018

I encountered this issue with a student who wrote this (a priori valid) code:

def triangle(x, y, w, h):
    """ float^4 -> Image """
    return draw_triangle(x, y, x + w, y, x + w/2, y + h)

If you add show_image(triangle(0, 0, 1, 1)) at the end of the file, the triangle is displayed as expected but if you enter this in the evaluation bar this fails with the following error:

=== Evaluation de : 'show_image(triangle(0, 0, 1, 1))' ===

-----
Erreurs à l'exécution (Interprète Python) :
-----

Erreur: ligne 1
==> Erreur Python: draw_triangle() missing 2 required positional arguments: 'x2' and 'y2'

Note that the problems does not come from show_image: if you only enter triangle(0, 0, 1, 1) in the evaluation bar, you get the same error.


There are two issues here:

  1. I guess a function named triangle was defined in the gfx module and it gets overridden by ours, which messes up internal stuff in gfx, hence the error. Maybe it would be helpful for the students to get a warning when they override an existing function.

  2. Why don't we observe the same behavior in the evaluation bar and in the file? Looks like something weird is happening…

  3. (Bonus issue) the error is always reported at line 1 independently of the location of my triangle function in the file, this is a bit confusing

(MrPython @ e8a212a)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant