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

Fix typing for Binary, Unary, and Logical Expressions #24

Merged
merged 152 commits into from
May 26, 2018
Merged

Conversation

ning-y
Copy link
Member

@ning-y ning-y commented May 22, 2018

This branch is blocking for #29, which uses the convenience function isBool and test file src/slang/utils/__tests__/rttc.ts added here.


Features

  • Violations of source typings raise relevant SourceErrors describing location of violation, what type was received, and what type was expected.
  • Additionally, fixed arrow functions being represented as 'object' when their value was printed.

For example,

> "a" < 1;
Line 1: Expected string on right hand side of operation, got number.
> true && 1;
Line 1: Expected boolean on right hand side of operation, got number.
> - false;
Line 1: Expected number, got boolean.
> - true;
Line 1: Expected number, got boolean.
> !0;
Line 1: Expected boolean, got number.
> -"asdf";
Line 1: Expected number, got string.
> 1 * "asdf";
Line 1: Expected number on right hand side of operation, got string.
> "1" === 1;
Line 1: Expected string on right hand side of operation, got number.
> "a" < 1;
Line 1: Expected string on right hand side of operation, got number.
> 1 < "1";
Line 1: Expected number on right hand side of operation, got string.

Issues fixed

Issues raised

ning-y and others added 30 commits May 14, 2018 10:48
Changes:
- Changed `Playground` component to a statefull one (extends `React.Component)
- add property `playgroundCode` to IApplicationState (bad practice,
change to a slice of the state instead)
- add interface `IPlaygroundProps` to denote the properties passed to
Playground
Once again, this is a WIP. Text typed into the playground editor will
stay in the playground (or rather, appear again) after leaving and
coming back.

Changes:
- added of action, actionCreator (updatePlaygroundCode)
- added a reducer under application's `reducer` function

Possible problems:
- Location of reducer
- Location of playgroundCode stored (as in previous commit)
Made a compromise by including an IPlaygroundState as part of IApplicationProps
This is a copy over of the current state of `./frontend/src/toolchain` at
source-academy/source-academy2 67d9184. It includes only source chapter 1, a new
specification (see [PR 6 at the
source-academy/source-academy2](source-academy/source-academy2#6)
repository).
The react types were added as a result of the `yarn add` command.
ning-y added 8 commits May 21, 2018 19:36
Next, change display so that if playground.output array is empty, initialise.
This is because the Output SFC tries to access an undefined output.consoleLogs.

output.consoleLogs is undefined after an Eval button click, because
EVAL_INTERPRETER_(SUCCESS|ERRORS) will try to access the last element of
playground.outputs, but the last element after playground.outputs is always a
CodeOutput for Eval button presses; and CodeOutput doesn't have a consoleLogs
property, so EVAL_INTERPRETER_(SUCCESS|ERRORS) copies over undefined as the new
ResultOutput or ErrorOutput's consoleLog property.
RTTC errors (type errors found at runtime) will now interrupt execution of the
program and return an error immediately.

Checks for unary expression arguments have been implemented.
Function type checks not yet implemented
@ning-y ning-y added Bug Something isn't working slang blocked Something else needs pass review first labels May 22, 2018
@ning-y ning-y added this to the Sprint 1 milestone May 22, 2018
@ning-y ning-y removed the blocked Something else needs pass review first label May 22, 2018
@ning-y ning-y closed this May 22, 2018
@ning-y ning-y reopened this May 22, 2018
@ning-y ning-y requested a review from evansb May 23, 2018 04:14
@ning-y ning-y added the blocking Finishing this opens up other stuff label May 24, 2018
@ning-y ning-y changed the base branch from functioning-ide to master May 25, 2018 03:27
=== and !== no longer raises errors.
@ning-y ning-y merged commit e8e664f into master May 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocking Finishing this opens up other stuff Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants