UCSD-PL / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
0 stars 7 forks source link

Syntax errors break the web Projection Boxes #34

Closed KasraF closed 1 year ago

KasraF commented 1 year ago

This code:

import matplotlib.pyplot as plt
import numpy as np
from typing import List

def plot(data: List[int]):
    """
    Plot the given list of integers as a bar chart.
    Use flower names for the x-axis
    """
    ## ---
    plt.bar(np.arange(len(data)), data)
    plt.xticks(np.arange(len(data)), ['rose', 'tulip', 'daisy', 'orchid']
    ## ---

plot([1, 86, 42, 54, 100])

Correctly shows an exception on the local build: image

But on the web, they fail silently: image

KasraF commented 1 year ago

Even locally, there's a corner case where if this code is the first to load, the Projection Boxes simply never show up, which might confuse the user. But at least even then they can see the exception in the Run panel.

It might be worth handling syntax errors in a more robust way such that they appear in the projection boxes similar to runtime errors both locally and on the web.

KasraF commented 1 year ago

Turns out the remove_comments_and_docstrings function was throwing an unhandled parse error, which happened to work in the local version. We need to be more careful with error handling, there are a lot of unwritten assumptions about what can fail in run.py and when.

Fixed in efd0bce.