unify_call() has imprecise error report. #435

Closed
opened 2024-06-26 14:01:05 +08:00 by lyken · 0 comments
Collaborator

Issue on Unifier::unify_call().

The ERROR: part is the Python error message (slightly paraphrased)

def func1(x: int32, y: int32, z: int32 = 5):
    pass

func1() # ERROR: Missing arguments: x, y
# PROBLEM: nac3core reports "Missing arguments: y, x", the order is reversed

func1(z = 23) # ERROR: Missing arguments: x, y
# PROBLEM: nac3core reports "Missing arguments: y, x", the order is reversed

func1(23, 45, x = 5) # ERROR: Got multiple values for x
# PROBLEM: nac3core reports "Unknown argument name: x". This is probably an oversight.

func1(23, 45, x = 5, y = 6) # ERROR: Got multiple values for x (y too but Python does not report it)
# PROBLEM: nac3core reports "Unknown argument name: y". Same as the above.

func1(23, 45, 67, z = 89) # ERROR: Got multiple values for z
# PROBLEM: nac3core reports "Unknown argument name: z". Same as the above.

func1(23, 45, z = 67, z = 89) # ERROR: Keyword argument repeated: z
# nac3core's parser panics when duplicate keywords are found, which I think is appropriate since Python considers this as a SyntaxError. Probably this is not an issue.

func1(23, 45, 67, 89) # ERROR: Function only takes from 2 to 3 positional arguments but 4 were given.
# PROBLEM: nac3core reports "Too many arguments. Expected 3 but got 4", which is not an interesting problem but it is less precise than Python.
Issue on `Unifier::unify_call()`. The `ERROR:` part is the Python error message (slightly paraphrased) ```python def func1(x: int32, y: int32, z: int32 = 5): pass func1() # ERROR: Missing arguments: x, y # PROBLEM: nac3core reports "Missing arguments: y, x", the order is reversed func1(z = 23) # ERROR: Missing arguments: x, y # PROBLEM: nac3core reports "Missing arguments: y, x", the order is reversed func1(23, 45, x = 5) # ERROR: Got multiple values for x # PROBLEM: nac3core reports "Unknown argument name: x". This is probably an oversight. func1(23, 45, x = 5, y = 6) # ERROR: Got multiple values for x (y too but Python does not report it) # PROBLEM: nac3core reports "Unknown argument name: y". Same as the above. func1(23, 45, 67, z = 89) # ERROR: Got multiple values for z # PROBLEM: nac3core reports "Unknown argument name: z". Same as the above. func1(23, 45, z = 67, z = 89) # ERROR: Keyword argument repeated: z # nac3core's parser panics when duplicate keywords are found, which I think is appropriate since Python considers this as a SyntaxError. Probably this is not an issue. func1(23, 45, 67, 89) # ERROR: Function only takes from 2 to 3 positional arguments but 4 were given. # PROBLEM: nac3core reports "Too many arguments. Expected 3 but got 4", which is not an interesting problem but it is less precise than Python. ```
lyken self-assigned this 2024-06-26 14:01:05 +08:00
lyken closed this issue 2024-06-27 14:33:46 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#435
No description provided.